Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I plot string vs float in python?

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?

like image 637
wthimdh Avatar asked May 22 '26 09:05

wthimdh


1 Answers

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()
like image 117
wthimdh Avatar answered May 24 '26 23:05

wthimdh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!