elections 12
elections 12

Reputation: 151

Is it possible to arrange only maximum limit of graph in Matlab?

I want to give a maximum value to my ylimit in a graph.

I know ylim command takes minimum and maximum value.

How to arrange maximum limit for y axis, without changing mimimum?

Upvotes: 2

Views: 85

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112659

You can't do that directly, but it's easy:

new_upper = 10; % desired new upper limit
yl = ylim; % store current limits
ylim([yl(1) new_upper]) % set current lower and new upper

If you prefer a single line you can use min (you can't index directly into the output of ylim):

ylim([min(ylim) new_upper])

Upvotes: 3

Related Questions