Domanda

I have a simple plot in Matlab but as you can see from the screenshot. There is a lot of white space on the right side of the graph after the end of the data series.

enter image description here

Any idea how to get rid of this white space and make the plot go right to the edge of the figure? Here is my code:

Plotx = plot(x);
hold on
PlotState = plot(Y);

set(Plotx,'Color','black','LineWidth',2.5);
set(PlotState,'Color','red','LineWidth',2.5);

set(gca, 'XTick',(1:3:62))
labels = time;
set(gca,'XTickLabel',labels(1:3:62))

grid on
È stato utile?

Soluzione 2

I found a solution. I manually adjust the limit of the x-axis, using:

set(gca,'XLim',[0 63])

Altri suggerimenti

This usually works for me:

axis tight;
xlim('auto');

You must select your figure, go back to the console and use those commands so they affect the last active figure.

EDIT: The above line should automatically make your graph axis very tight on your data. For more fine control, you may want to define the axis limits manually:

 axis([xmin,xmax,ymin,ymax])
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top