How do I change the interval on one of my axis at different points along the axis?

3 vues (au cours des 30 derniers jours)
Andrew
Andrew le 5 Déc 2022
Réponse apportée : Voss le 6 Déc 2022
I'm currently plotting data but some of it is too condensed to visualize properly on the current scale. Here's what my plot looks like:
As you can see I attempted to use the xticks() and xtickslabel() functions on the left end of the axis but that only added ticks, not changed the interval. What I need to do is to have the range from 0.1-1 be the same distance as from 1-2, that way the condensed data on the left side can be expanded to better visualize what is occuring. Thanks in advance!

Réponses (2)

Maik
Maik le 6 Déc 2022
You can try setting axes properties that should keep the scale.
x1 = 0:0.1:40;
y1 = cos(x1).^2;
x2 = 1:0.2:20;
y2 = sin(x2);
f = figure;
ax1 = axes(f);
plot(ax1,x1,y1,'-r')
% Plot second graph with different scale
ax2 = axes(f);
plot(ax2,x2,y2,'-.b')
%% calling this property makes the axes hold
ax2.Color = 'none';
%%
ax1.FontSize = 8;
ax1.XColor = 'r';
ax2.FontSize = 8;
ax2.XColor = 'b';

Voss
Voss le 6 Déc 2022
Maybe this will be good enough:
set(gca(),'XScale','log')

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by