12

I need to draw a plot looks like this:

enter image description here

Is it possible? How can I do this?

2
  • I believe the key word is "stripchart". Maybe you can adapt matplotlib.sourceforge.net/examples/animation/… ? Commented May 21, 2012 at 5:28
  • 2
    Is there any reason you can't just flip the x and y coordinates? Commented May 21, 2012 at 5:46

1 Answer 1

17

I don't know what is your data for ... but here is a 'vertical' plot of hypothetical oxygen levels in near sea surface...

Note that nothing special is required. Simply order your x and y values such that a line drawn from the first coordinate to the second and so on gives the vertical line you desire.

(The one special thing I've done here -- which may or may not be what you want -- is put the xticks at the top of the plot, using tick_top.)

import matplotlib.pyplot as plt

# define data

Oxygen = [ 0.1 , 0.5, 1, 10, 15, 20, 15, 10, 1, 0.5, 0.5]
Depth  = [ 0,     1,  2,  4,  8, 10, 12, 14, 16, 20, 40 ]

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot(Oxygen, Depth, 'go--')
ax.xaxis.tick_top()

ax.set_ylabel('depth')
ax.set_ylim(50, 0)
ax.set_xlim(0, 25)
ax.set_xlabel('Oxygen level [ppm]')

plt.show()

This yields: enter image description here

I hope it helps ...

Sign up to request clarification or add additional context in comments.

1 Comment

@wtm, notice that one little improvement you could do for aesthetic appeal, is to put the xtitle (Oxygen level) on top, instead of where it is now. But I won't spoil all the fun and let you discover alone ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.