Is it possible to manipulate a plot axis; i.e., divide values by 1000 so that the x axis range is 0 to 300 instead of 0 to 300000 and also get rid of exponential notation?
    12 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Srh Fwl
 el 24 de En. de 2021
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 25 de En. de 2021
            I am making X–Y plots of results from very long simulations.  Right now, my plots are unsightly because:
- The X axis goes from 1 to hundreds of thousands of femtoseconds.
- Also, I don't get axis labels like "300000" (for example). I get scientific notation but it doesn't look good. I get "3.0" (for example) with a tiny "x 10^5) below the labels. I don't know how to get "300000" or add the scientific notation into each label on the axis.
Here is my plotting command:
plot(Velocity.TotalVelocity)
I know I could make an X–Y plot and divide the X (time) values by 1000 but then I'd end up with another huge array.  So I'm wondering if there's a way to get the X values to appear in the plot as divided by 1000.
Thank you for any advice.
0 comentarios
Respuesta aceptada
  Rik
      
      
 el 24 de En. de 2021
        You can explicitly set the tick labels:
plot(linspace(0,3e5,10),rand(1,10))
xticklabels(arrayfun(@(x)strrep(sprintf('%.1e}',x),'e','x10^{'),xticks,'UniformOutput',false))
2 comentarios
  Walter Roberson
      
      
 el 25 de En. de 2021
				Note that when you do this, data tips will not agree with the displayed values unless you also configure custom data tips.
Más respuestas (1)
  Steven Lord
    
      
 el 25 de En. de 2021
        If you access the numeric ruler associated with the coordinate axes using the XAxis, YAxis, or ZAxis properties of the axes object, the ruler has properties that may help you customize the appearance. See the list of properties you can customize on this documentation page.
x = 1:10;
y = x.^2;
h = plot(x, y);
ax = ancestor(h, 'axes');
xax = ax.XAxis;
xax.Exponent = 1;
0 comentarios
Ver también
Categorías
				Más información sobre Axes Appearance 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!





