frazman
frazman

Reputation: 33213

how to change axis values in python?

I am trying to change the values of axis...but just the axis text and not the graph.

For example, I have data as

x = [10,20,30,40]
y = [100,200,3000,400000]

Now,the graph is between x and y

so

plt.plot(x,y)

but in the axis I want

ax_x = [ex/10 for ex in x]
ax_y = [math.log(y) for ey in y]

And the axis of this graph has ax_x and ax_y as values instead of x and y?

How do i do this?

Upvotes: 1

Views: 2750

Answers (1)

prgao
prgao

Reputation: 1787

plt.gca().set_xticks(x, minor=False)
plt.gca().set_yticklabels(ax_x)
plt.draw()

Similar for y axis

Upvotes: 3

Related Questions