Discussion:
[Matplotlib-users] stem plot with horizontal offset (BaseValue)
ssinfod
2015-03-31 18:31:15 UTC
Permalink
Hello,

I found this stem plot example:
http://matplotlib.org/examples/pylab_examples/stem_plot.html

I would like to add an horizontal offset to the step plot. (Ex: +2 on Y
axis)
What is the equivalent of the Matlab "BaseValue" offset in matplotlib.

See Reference:
http://www.mathworks.com/help/matlab/ref/stemseries-properties.html
http://stackoverflow.com/questions/21913995/vertically-offset-stem-plot

Thanks,
ssinfod




--
View this message in context: http://matplotlib.1069221.n5.nabble.com/stem-plot-with-horizontal-offset-BaseValue-tp45297.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Sterling Smith
2015-03-31 19:04:54 UTC
Permalink
I’m not going to claim this is the final answer, but in the documentation for the stem function[1], it specifically says that the horizontal line is drawn at 0.

A workaround is to subtract the offset from your data, and relabel the axes….

[1]http://matplotlib.org/api/pyplot_api.html?highlight=stem#matplotlib.pyplot.stem
Post by ssinfod
Hello,
http://matplotlib.org/examples/pylab_examples/stem_plot.html
I would like to add an horizontal offset to the step plot. (Ex: +2 on Y
axis)
What is the equivalent of the Matlab "BaseValue" offset in matplotlib.
http://www.mathworks.com/help/matlab/ref/stemseries-properties.html
http://stackoverflow.com/questions/21913995/vertically-offset-stem-plot
Thanks,
ssinfod
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/stem-plot-with-horizontal-offset-BaseValue-tp45297.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
ssinfod
2015-03-31 19:59:36 UTC
Permalink
In fact, I would like to draw other stem plots each at different offset.

Ex:
-+----_-----_--+-----_---

-+----_---+-_--+--_-----

-+--+-----_------+-----_-


I also found vlines but I have the same problem I don't know how to add a
horizontal offset to the values.
Ex:
import numpy
from matplotlib import pyplot
x = numpy.arange(10)
y = numpy.random.random(10)-0.5
pyplot.vlines(x, 0, y, color='red', bottom=2) # Stems
pyplot.plot(x, y, 'D') # Stem ends
pyplot.plot([x.min(), x.max()], [0, 0], '--') # Middle bar
pyplot.grid(True)
pyplot.show()

ssinfod




--
View this message in context: http://matplotlib.1069221.n5.nabble.com/stem-plot-with-horizontal-offset-BaseValue-tp45297p45300.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
ssinfod
2015-04-03 01:59:00 UTC
Permalink
It seems the 'bottom' parameter is the best for me.

Here is the code:
from pylab import *

x = linspace(0.1, 2*pi, 10)
markerline, stemlines, baseline = stem(x, cos(x), '-.', bottom=.5)
setp(markerline, 'markerfacecolor', 'b')
setp(baseline, 'color','r', 'linewidth', 2)

show()

Thanks for your inputs.
ssinfod



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/stem-plot-with-horizontal-offset-BaseValue-tp45297p45327.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Andrew Dawson
2015-03-31 19:17:20 UTC
Permalink
Looking at the source code indicates there is a 'bottom' keyword which
looks like it controls this, see
https://github.com/matplotlib/matplotlib/blob/v1.4.3/lib/matplotlib/axes/_axes.py#L2295
Post by ssinfod
Hello,
http://matplotlib.org/examples/pylab_examples/stem_plot.html
I would like to add an horizontal offset to the step plot. (Ex: +2 on Y
axis)
What is the equivalent of the Matlab "BaseValue" offset in matplotlib.
http://www.mathworks.com/help/matlab/ref/stemseries-properties.html
http://stackoverflow.com/questions/21913995/vertically-offset-stem-plot
Thanks,
ssinfod
--
http://matplotlib.1069221.n5.nabble.com/stem-plot-with-horizontal-offset-BaseValue-tp45297.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...