stem plot with horizontal offset (BaseValue)

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.

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

···

On Mar 31, 2015, at 11:31AM, ssinfod <ssinfod@...287...> wrote:

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.

------------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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

···

On 31 March 2015 at 19:31, ssinfod <ssinfod@…287…> wrote:

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.


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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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.

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.