Closed 153957 closed 9 years ago
Example:
Code:
from artist import Plot
from numpy import linspace, cos, sin, pi
plot = Plot(width=r'.5\linewidth', height=r'.5\linewidth')
r = linspace(1, 5, 100)
phi = linspace(0, 4.5 * pi, 100)
x = r * cos(phi)
y = r * sin(phi)
plot.plot(x, y, mark=None)
plot.add_pin('start', relative_position=0, use_arrow=True)
plot.add_pin('half', relative_position=.5, use_arrow=True)
plot.add_pin('46\%', relative_position=.46, use_arrow=True, location='above')
plot.add_pin('end', relative_position=1, use_arrow=True, location='below')
phi = linspace(0, 2 * pi, 10)
x = 6 * cos(phi)
y = 6 * sin(phi)
plot.plot(x, y, mark=None)
plot.add_pin('start', relative_position=0, use_arrow=True, location='above right')
plot.add_pin('half', relative_position=.5, use_arrow=True, location='above left')
plot.add_pin('70\%', relative_position=.7, use_arrow=True, location='below')
plot.add_pin('end', relative_position=1, use_arrow=True, location='below right')
plot.set_xlimits(-8, 8)
plot.set_ylimits(-8, 8)
plot.save_as_pdf('spiral')
Nice!
I like your demo.
How do you want to handle log plots? Similar to how it was done: use the log10(...) value(s) to calculate the length?
That should work, right?
Yea, just have to do it carefully, converting in the right places.. and now also consider y log.
Not so easy for semilog axes...
The position of the pins will(/should) change if one of the axes are log..
For calculating the path lengths:
if self.xmode == 'log':
x = np.log10(np.array(x))
if self.ymode == 'log':
y = np.log10(np.array(y))
and then also some logs to do the interpolation correctly and then convert back to normal values (10 **
).
That should fix it..
Good to merge?
Great! Time well spent. I'll merge it right away.
As discussed in #21. Now the path length of the line described by x, y is taken into consideration. relative_position is now a fraction of that path length.
Todo: