 # Line plot orientation

Hi Folks,

I am trying to do something similar to
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_hist.html,
but with a line plots instead of histograms.
My problem is how to set orientation of line plot if there is no
'orientation' argument (line axHisty.hist(y, bins=bins,
orientation='horizontal') in the example).

Thanks a lot

Since a line plot doesn't really have an orientation, this might be a lot simpler than you think. If I understand your question, you can just switch your x and y data to get the desired behavior.

Continuing the example you link to, just remove the lines that create the histogram (last 4 lines before plt.show) and replace with normal plot commands; for example:

bins = np.arange(-lim, lim + binwidth, binwidth)
x_hist, _ = np.histogram(x, bins=bins)
y_hist, _ = np.histogram(y, bins=bins)
x_bin_centers = y_bin_centers = (bins[:-1] + bins[1:])/2.
axHistx.plot(x_bin_centers, x_hist)
axHisty.plot(y_hist, y_bin_centers)
plt.show()

The first line above marks the last line in the example script that you should keep. Note that you don't have to use histogram data (x_hist, y_hist); I only do so to simplify the example. Also, x_bin_centers and y_bin_centers are only equal because the scatter data is square.

Is this what you were going for?

-Tony

···

On Sep 11, 2010, at 12:00 PM, Radek Machulka wrote:

Hi Folks,

I am trying to do something similar to
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_hist.html,
but with a line plots instead of histograms.
My problem is how to set orientation of line plot if there is no
'orientation' argument (line axHisty.hist(y, bins=bins,
orientation='horizontal') in the example).

Thanks a lot