I've been researching this a while and can't find what I need - I can change the limits on the axis for graphs etc without a problem, but what I need is to change the numbers on the scale, without actually changing the scale of the graph (not sure if I'm explaining right). So I have a pcolor plot, but wish to change the numbers on the axes, without changing the axes limits (So I still want to show the same data, but with the axes reading different values) - for example, the current values multiplied by a constant. Thanks

1 comentario

Veronica Lucchese
Veronica Lucchese el 27 de Feb. de 2019
Editada: Veronica Lucchese el 27 de Feb. de 2019
In matlab, the scale is called the c-axis. In order to manipulate the scale, you must manipulate the c-axis values
type in the command window:
caxis([0 0.1]) or whatever you want you scale limits to be

Iniciar sesión para comentar.

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016

1 voto

You mean to change the ticks of your axis. For example
x=0:10
y=cos(x)
plot(x,y)
number_of_ticks=5
xt=xlim
set(gca,'xtick',linspace(xt(1),xt(2),number_of_ticks))

10 comentarios

Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Thanks, but I'm not really sure, I tried doing that but it didn't work. I have the plot but I want to edit the numbers on the axis, but using that code, it returned an error.
Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016
It depends on what you did, post what you have tried
Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016
x=randi(10,10)
pcolor(x)
number_of_ticks=5
xt=xlim
set(gca,'xtick',linspace(xt(1),xt(2),number_of_ticks))
So it changes the values on the axis, but it still goes from zero to ten, but I want it to read from zero to 500 but have it say 500 where it currently says 10 if you get me? Thanks
Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
n=numel(get(gca,'xtick')),
xt=arrayfun(@num2str,linspace(0,500,n),'un',0),
set(gca,'xticklabel',xt)
Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Yes! Thank you so much, I've been trying to make it work for four hours!
Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Sorry to be a pain, but I can't get it to work on a GUI, any ideas why please?
Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
Post the part of your code
Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016
handles.x=randi(10,10)
pcolor(handles.x)
handles.n=numel(get(gca,'xtick')),
handles.xt=arrayfun(@num2str,linspace(0,500,handles.n),'un',0),
set(gca,'xticklabel',handles.xt)
Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
This works for me
Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
I don't understand why it still won't work for me, I can't see what's wrong with it

Iniciar sesión para comentar.

Más respuestas (1)

Kelly Kearney
Kelly Kearney el 18 de Abr. de 2016

0 votos

You can simply change the YTickLabel property:
ax = axes;
plot(1:10)
ax.YTickLabel = strtrim(cellstr(num2str(2 * ax.YTick')))

1 comentario

Jamie Shelley
Jamie Shelley el 18 de Abr. de 2016
Thanks, but that didn't work, it just deleted the plot from the figure

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Abr. de 2016

Editada:

el 27 de Feb. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by