1

I am drawing graph in tkinter using matplotlib. Here is code:

data = [[left[0],right[0]]]
X = ["left", "right"]

fig = Figure(figsize=(6, 4), dpi=96)
ax = fig.add_subplot(111)

barlist = ax.bar(X , data[0], color = 'b', width = 0.25)


barlist[0].set_color('r')

graph = FigureCanvasTkAgg(fig, master=win)
canvas = graph.get_tk_widget()
canvas.place(x= 150, y = 5)

How do I set y axis limit (maximum value)?

0

1 Answer 1

2

You could do:

ax.set_ylim(lower_limit,upper_limit)
Sign up to request clarification or add additional context in comments.

5 Comments

While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.
To my understanding, the question was how to set the axis limit in a matplotlib plot. My answer shows how to do that. I am unaware of any "how and why" or "limitations and assumptions" on which I could elaborate further.
@AdrianMole actually, I've noticed by looking at your profile that your usual focus is not on python ... so may I ask whether you found my answer by some review queue?
You are correct - it came up in Review (Low Quality Posts). So, somebody else had sent it there and it seems that I reviewed it too hastily - not looking more carefully at the context. Please accept my apologies! (I can delete the comment but, alas, cannot undo my review.)
No need to apologize. Thanks for the feedback. I'd suggest to leave the comments.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.