2
$\begingroup$

I have data1, whose first column is, in fact, the date (i.e. number of days from 1900/1/1). I then create a 3D plot as below:-

data1 = {{42219, 33, 71}, {42218, 35, 72}, {42217, 36, 72.5}, {42216, 36.5, 73}};
ListPointPlot3D[data1]

enter image description here

As you can see, 42216 and 42219 etc. are shown on the axis label. But I want to show the date yyyy/mm/dd instead. Thus I tried to convert data1's first column into the date format:-

data1[[All, 1]] = DateObject[{1900, 1, 1}] + data1[[All, 1]]*Quantity[1, "Days"];
data1
ListPointPlot3D[data1]

I am successful to convert the format but failed to create the plot. I obtained this error as output:-

Last::nolast: {} has zero length and no last element.

How can I show the date format in the axis? Many thanks!

$\endgroup$
2
  • $\begingroup$ You want to change the Ticks so try tickspecs1 = Map[{#, DateObject[{1900, 1, 1}] + #*Quantity[1, "Days"]} &, data1[[All, 1]] ]; then ListPointPlot3D[data1, Ticks -> {tickspecs1, Automatic, Automatic}] although a date string format would look better. $\endgroup$
    – Hans
    Jun 12, 2018 at 2:57
  • $\begingroup$ Just saw the format you want the ticks in so try Map[{#, DateString[ DateObject[{1900, 1, 1}] + #*Quantity[1, "Days"], {"Year", "/", "Month", "/", "Day"}]} &, data1[[All, 1]] ] instead. $\endgroup$
    – Hans
    Jun 12, 2018 at 3:05

1 Answer 1

5
$\begingroup$

Try

  data1 = {{42219, 33, 71}, {42218, 35, 72}, {42217, 36, 72.5}, {42216, 
    36.5, 73}};
tickspecs1 = Map[{#, DateString[ DateObject[{1900, 1, 1}] + #*Quantity[1, "Days"], {"Year", "/", "Month", "/", "Day"}]} &, data1[[All, 1]] ];
ListPointPlot3D[data1, Ticks -> {tickspecs1, Automatic, Automatic}] 

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.