Issue
I would like to do this :
I have this python code :
import numpy as np
import pylab as plt
a = np.array([1,2,3,4,5,6,7,8,9,10])
b = np.array([7,8,6,3,2,1,5,8,4,15])
c = plt.plot(a,b,'.')
d = 5
plt.text(2,3, "d = "+d) #This line is the problem because i have not the value of d !
plt.show()
So actually I just want to display the value of d and also I want to display the value of d but relatively for instance at the bottom right but not with some coordinates. Is it possible to do this with Python ?
Solution
You can use the transform
argument to place in relative coordinates from 0.0
to 1.0
for example
plt.text(0.5,
0.67,
"d = {}".format(d),
transform=plt.gca().transAxes)
In this local system (0, 0)
is the lower-left and (1, 1)
is the upper-right of the plot. Here is a good reference for placing and rotating text at various locations on the plot.
Answered By - Cory Kramer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.