Pau
April 29, 2011, 10:54am
1
Hello,
I am trying to print in the plot the value of a time variable which I
obtain like this
Time = MBH_inst[0] # Column 1
This should be placed on the top right part of the plot showing the current time
Time = XXX yrs
But I do not know how to pass this to ax.annotate:
ax.annotate('Time = ', size=18, xy=(3, 1), xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
Thanks,
Pau
You could use Python string formatting, like so:
ax.annotate('Time = %s' % Time, size=18, xy=(3, 1), xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
···
On 04/29/2011 06:54 AM, Pau wrote:
Hello,
I am trying to print in the plot the value of a time variable which I
obtain like this
Time = MBH_inst[0] # Column 1
This should be placed on the top right part of the plot showing the current time
Time = XXX yrs
But I do not know how to pass this to ax.annotate:
ax.annotate('Time = ', size=18, xy=(3, 1), xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
Thanks,
Pau
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
Hi,
Pau <vim.unix@...982...>
Hello,
I am trying to print in the plot the value of a time variable which I
obtain like this
Time = MBH_inst[0] # Column 1
This should be placed on the top right part of the plot showing the current
time
Time = XXX yrs
But I do not know how to pass this to ax.annotate:
ax.annotate('Time = ', size=18, xy=(3, 1), xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
Maybe like this:
ax.annotate('Time = %f'%(MBH_inst[0],), size=18, xy=(3, 1), xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
?
You can also adjust the number of shown digits right of the comma by setting
it up like this: %0.2f etc.
Just look it up in the python documentation (search hints: python string
format).
Wish you the best,
Malte