Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.5K Views
|
7 Replies
|
1 Total Like
View groups...
Share
Share this post:

The X-axis ticks in ListPlot of TemporalData?

Posted 2 years ago


I googled the answer and get this, but I don't like the X-axis. I don't know how to improve it.
Thank you!

POSTED BY: Daniel Niu
7 Replies

It seems to be a bug introduce in v13.0 and fixed in v13.1. In the meanwhile you can use Normal. See this mathematica.stackexchange question.

Posted 2 years ago

Since your t has 5 items and each column in your s has 5 items I am guessing you want to plot each column of s using the values of t on your horizontal axis

Mathematica usually deals with rows so I am going to use Transpose to exchange your rows and columns of s.

ListPlot uses 1,2,3,4,5 for the horizontal axis unless you have pairs of numbers like {{-1.,1},{-0.5,4},{0.,7},{0.5,10},{1.,13}}

So I am going to write a little function that will pair up items from t along with individual items from columns in s. That function will again use Transpose to pair up {-1.,-0.5,0.,0.5,1.} and {1,4,7,10,13} and turn that into {{-1.,1},{-0.5,4},{0.,7},{0.5,10},{1.,13}} for the first column and do the same for the rest of your columns. And, by making all these changes to the data, the labels on the x axis of your plot match the values in your list t.

Try

s={{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15}};
t=Range[-1,1,0.5];
f[v_]:=Transpose[{t,v}];
ss=Map[f,Transpose[s]];
ListPlot[ss]

and see if my guesses are correct. I realize that may seem to be complicated just to get the labels on the x axis.

POSTED BY: Bill Nelson
Posted 2 years ago

Wow, The code is beautiful and exactly what I want. I have learned a lot from the code, thank you!

POSTED BY: Daniel Niu
Posted 2 years ago

What do you mean by

I need them to be normal x axis

The code above generates a plot that has an x axis ranging from -1 to 1, which is the range of values in t.

POSTED BY: Rohit Namjoshi
Posted 2 years ago

enter image description here My axis looks like this, which looks like time not the normal x axis, thank you.

POSTED BY: Daniel Niu
Posted 2 years ago

Interesting in version "13.1.0 for Mac OS X ARM (64-bit) (June 16, 2022)" I get this

enter image description here

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Wow, Indeed interesting. In Win 11, Mathematica 13.0, I got x axis with time.

POSTED BY: Daniel Niu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard