Issues Using Functions to Rotate XTickLabels found on FEX
Mostra commenti meno recenti
I am trying to rotate my x tick labels to a 60 degree angle. My labels are strings instead of integers. I have tried 3 separate functions from the file exchange site and I am having issues with all of them which I cannot figure out. Any help would be greatly appreciated on any aspect of my code or how I am implementing the functions.
Here is a piece of my code (Note: my data for this piece has 20,197 rows and therefore 20,197 data points for the date but it only spans about 25 days):
close all
y = data.rod1;
k = 1;
gmt = x(:,1);
% Conversion from serial date in GMT to PST
localt = gmt - 0.291666666395031;
date = datestr(localt,'mm/dd/yyyy');
%rotateXLabels
% Axial Load
figure(1)
plot(localt,y(:,22),'r',localt,y(:,23),'b')
grid on
set(gca,'XTickLabel',date)
rotateXLabels(gca,60)
set(gca,'XMinorTick','on','YMinorTick','on')
ylim([0 800])
title(['Rod ',num2str(k), ' Axial Force'])
xlabel('Date')
ylabel('Rod Load [kips]')
legend(['Rod',num2str(k),'N Load (Primary)'],['Rod',num2str(k),'S Load (Secondary)'])
set(legend,'FontSize',9)
When I use rotateXLabels.m (by Ben Tordoff) all the dates are the same on the x-axis (see first figure). In reality the dates should span from 7/31/2013 to 8/24/2013. I have double checked my input data that this is correct.
If I use xticklabel_rotate.m (by Brian Katz) the dates do not update when I zoom in on the plot (see second and third figures). From my understanding this is an issue with datetick
Lastly, I tried rotateticklabel.m (by Andrew Bliss) but I get this error:
Error using text
Each string specified must have a corresponding set of coordinates
Error in rotateticklabel (line 56)
th=text(b,repmat(c(1)-.1*(c(2)-c(1)),length(b),1),a,'HorizontalAlignment','right','rotation',rot);
I have tried different variations of each function and tried to eliminate my errors but I think I've just muddied my understanding. Ideally, I want to rotate my x ticks at 45 or 60 degrees, have then update when zooming, span the correct dates, and show each of the 25 days.
Thank you for any help!
_Link to FEX: http://www.mathworks.com/matlabcentral/fileexchange/?search_submit=fileexchange&query=rotate+x+ticks&term=rotate+x+ticks_



Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Grid Lines, Tick Values, and Labels in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!