3

How can I plot string versus float type graph using pylab?

x = ['PARIS','LONDON']

y = [2.39, 3.41]

how can I plot x versus y?

1
  • 1
    You need to assign the horizontal relationship to the values of y and then assign your strings as ticks. Commented Sep 23, 2014 at 15:07

1 Answer 1

11

Many thanks to Myles Baker, here is the solution:

import pylab as pl
x = [0,1]
xTicks = ['LONDON','PARIS']
y = [2.39, 3.41]
pl.xticks(x, xTicks)
pl.xticks(range(2), xTicks, rotation=45) #writes strings with 45 degree angle
pl.plot(x,y,'*')
pl.show()
Sign up to request clarification or add additional context in comments.

1 Comment

Is there an equivalent way to do this for a single axes? I tried ax.set_xticks() and ax.set_xticklabels(), and they seemed to be ignored...

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.