Rotating xtick labels on 2nd xaxis

Hi,
I am very close to being absolutely desperate. I am a beginner in Matlab, trying to produce my first graph since I want to get rid of the excel restrictions.
However, I am trying to rotate my x-axis tick labels, which are dates, on the upper x axis and do not come to any satisfying result. I tried all scripts including xticklabe_rotate90, rotateticklabel, rotatetl, but it does not seem to work for my problem.
For a better understanding I attached you my generated code and hope you can help.
Thanks in advance. In Case you need my database, let me know.
----
DEdata = importdata('1.xls');
DEdim=size(DEdata);
wide=DEdim(1,2);
length=DEdim(1,1);
counter=linspace(0,wide-1,wide);
DEdata(length+1,1:wide)=counter;
x=DEdata(length+1,2:wide);
y=DEdata(3:length,2:wide);
% % plots Profile
clf;
plot (x,y,'Marker','.','LineStyle','none','Color',[0 0 0]);
ax1=gca;
set(ax1, 'XTick', 1:wide-1,'XTickLabel', {DEdata(2,2:wide)});
axis([0 wide -0.3 0.3]) ; % Max. Ausdehnung der Wertebereiche
xlabel ('days after rain'); %Bezeichnung X Achse
ax2=axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'Color','none');
set(ax2, 'XTick', 1:wide-1,'XTickLabel',{'15.02.', '31.12', '19.01.',...
'08.03.', '20021119', '20001028', '20020324', '20021018', '20020409',...
'20000403', '20010321', '20010524', '20000521', '20010625'})
ylabel ('IF');
axis([0 wide -0.3 0.3]) ; % Max. Ausdehnung der Wertebereiche
%%Plot Horizontal Line
line([0 20],[0 0],'LineStyle','--','Color',[0.8 0.8 0.8]);
line([0 20],[-.03 -.03], 'Color', [0 0 0]);

Respuestas (1)

Daniel Shub
Daniel Shub el 30 de Nov. de 2011

0 votos

In general, when asking questions you need to supply more than it doesn't work. What did you get and what did you expect to get.
It sounds like the files on the FEX do not handle an axis on top correctly. I haven't tried them so I do not know. You could either contact the maintainers of the packages or use them as a starting point and put together your own.
With a little time and effort you should be able understand what rotateticklabel is doing and make it work for a top axis.
That said trying to make nice figures in MATLAB is difficult, not as difficult as MS Excel, but still difficult.

Categorías

Preguntada:

Ulf
el 29 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by