Unable to reverse the order of numbers on the Y-axis
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chris Park
el 22 de Mayo de 2018
Comentada: Ameer Hamza
el 22 de Mayo de 2018
plot(1,a)
bar3c(flipud(dam_tot(:,:,a)))
colorbar;
colormap(jet);
caxis([0 0.1]);
set(gca,'XTick',[1:1:11]);
set(gca,'XTickLabels',round((minSpeedRef:speed_range/(resolution-1):maxSpeedRef)));
xtickangle(-45)
set(gca,'YTick',[1:1:11]);
ax.YDir = 'reverse';
set(gca,'YTickLabels',round(flipud((minTorqueRef:torque_range/(resolution-1):maxTorqueRef))));
ytickangle(45)
xlabel('Speed');
ylabel('Torque');
title(strcat(fname{a},' Damage per Load Case'),'fontsize',14);
set(gcf,'units','inches','position',[0 .5 7 5.5])
set(gca,'FontSize',12)
1 comentario
Benjamin Kraus
el 22 de Mayo de 2018
I can't run your code without knowing more about a and dam_tot (and other variables). Setting YDir to reverse should flip the order of the numbers on the Y-axis. Can you post a screenshot of what you are seeing, and why it doesn't match what you are trying to get?
Respuesta aceptada
Ameer Hamza
el 22 de Mayo de 2018
Editada: Ameer Hamza
el 22 de Mayo de 2018
Your line
ax.YDir = 'reverse';
is not actually doing what you think it is doing. You should add the following line before it.
ax = gca;
ax.YDir = 'reverse';
or use set()
set(gca, 'YDir', 'reverse');
Your code is not giving an error because it is a valid MATLAB syntax. It creates a new struct object with field YDir.
9 comentarios
Más respuestas (1)
Benjamin Kraus
el 22 de Mayo de 2018
Without being able to run your code this is just speculation, but it looks like you may be double-flipping your Y-axis tick labels. Two lines of code stick out:
ax.YDir = 'reverse';
set(gca,'YTickLabels',round(flipud((minTorqueRef:torque_range/(resolution-1):maxTorqueRef))));
You have flipud in the call to set the YTickLabels, which may mean you are assigning the wrong tick labels to each tick (essentially assigning them in reverse order). Try commenting out the second line (the one that is setting YTickLabels) and see if it looks like the ticks are in the correct order. If so, remove the flipud.
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!