How can I specify axis spacing?

43 Ansichten (letzte 30 Tage)
Susan
Susan am 12 Jun. 2019
Kommentiert: Star Strider am 12 Jun. 2019
Hey Guys,
I am plotting a figure that x takes values of [4 8 16 32 64 128 256 512 1024]. I use
%%
x = [4 8 16 32 64 128 256 512 1024];
plot(x, Y)
set(gca,'XTick',x)
The problem is the x-axis = [4 8 16 32 ] overlap and it's not readable. How can I fixed that? Many thanks in advance!untitled.jpg
  2 Kommentare
Jan
Jan am 12 Jun. 2019
Use a logarithmic scale. Then the ticks are equi-distant.
Susan
Susan am 12 Jun. 2019
Thank you so much! Could you please take a look at the following comment and let me know if you have any sugesstions? Thanks in advance!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 12 Jun. 2019
One option:
x = [4 8 16 32 64 128 256 512 1024];
plot(log2(x), Y)
set(gca,'XTick',log2(x), 'XTickLabel',x)
It would be a bit easier if we knew ‘Y’, and what you wnat it to look like.
  4 Kommentare
Susan
Susan am 12 Jun. 2019
Thank you SO much!
Star Strider
Star Strider am 12 Jun. 2019
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by