Why is this plot deleted?

As soon as I get to set(gca) the plot disappears. If I continue I get the date formatted tick labels but I don't show any plot. Thanks
plot(matrix(:,1),matrix(:,7));
axis tight
xlabel('Date');
ylabel('PnL');
set(gca,'xtick',linspace(733645,736117,50)); % label 10 ticks using start/end
datetick('x',2,'keepticks'); %convert serial number to date
ax=gca; % get current axis
ax.XTickLabelRotation=45; % rotate ticks 45 degrees

 Respuesta aceptada

Star Strider
Star Strider el 15 de Oct. de 2015

0 votos

Apparently, the first set call was the problem. I don’t have your ‘matrix’ variable, but for datetick to work, matrix(:,1) have to be date numbers. After that, combine the set arguments in one call.
This works:
matrix(:,1) = linspace(733645,736117,20);
matrix(:,7) = randn(1,20);
plot(matrix(:,1),matrix(:,7));
axis tight
xlabel('Date');
ylabel('PnL');
datetick('x',2,'keepticks'); %convert serial number to date
set(gca,'xtick',linspace(733645,736117,50), 'XTickLabelRotation',45, 'FontSize',6); % label 10 ticks using start/end

4 comentarios

Cary
Cary el 15 de Oct. de 2015
Thanks Star!
Star Strider
Star Strider el 15 de Oct. de 2015
Editada: Star Strider el 15 de Oct. de 2015
My pleasure!
If my Answer solved your problem, please Accept it!
Cary
Cary el 15 de Oct. de 2015
I was on mobile earlier I'm sorry, but I accepted now. Thanks again
Star Strider
Star Strider el 15 de Oct. de 2015
As always, my pleasure. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 15 de Oct. de 2015

Comentada:

el 15 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by