How can we had special data next to a matplotlib figure For example
fig, ax = plt.subplots()
plt.legend()
plt.title()
plt.annotate()
Is there a way to put a box next the plot with additionnal data (I mean real textual comments ,....)
How can we had special data next to a matplotlib figure For example
fig, ax = plt.subplots()
plt.legend()
plt.title()
plt.annotate()
Is there a way to put a box next the plot with additionnal data (I mean real textual comments ,....)
You can use matplotlib's text
function.
#data is your normal string variable only.
data = ( 'CPK = \n'
'Cp = \n'
... # Rest of your text
)
plt.text(1.20,0,data)
The syntax is plt.text(x_co-ordinate,y_co-ordinate,string_to_print)
. The figure is ([0-1],[0-1])
Finally it works like this for me :
dict = OrderedDict()
dict['key1'] = stuff
dict['keyn'] = stuff
statdesc = '\n'.join(['%s : %s' % (key, value) for (key, value) in dic.items()])
plt.text(xmax+.1*(xmax-xmin), 0, statdesc)
In addition to Spandan's answer above, I would suggest to look at the Postprocessing part of the answer here.
The same matplotlib.pyplot.subplots_adjust
and matplotlib.pyplot.tight_layout
functions can be used with text as well.