2
$\begingroup$

I have a ListPlot3D with custom axis labels that I am scrolling with Manipulate. My issue is that the axis labels scroll away as the plot is scrolled. The commands below reproduce the problem that I am having.

Thanks,

Edmund

tickLabels = {{1, ""}, {2, ""}, {3, ""}, {4, ""}, {5, "lv1"}, {6, 
""}, {7, ""}, {8, ""}, {9, ""}, {10, "lv2"}, {11, ""}, {12, 
""}, {13, ""}, {14, ""}, {15, "lv3"}, {16, ""}, {17, ""}, {18, 
""}, {19, ""}, {20, "lv4"}, {21, ""}, {22, ""}, {23, ""}, {24, 
""}, {25, "lv5"}, {26, ""}, {27, ""}, {28, ""}, {29, ""}, {30, 
"lv6"}, {31, ""}, {32, ""}, {33, ""}, {34, ""}, {35, "lv7"}, {36, 
""}, {37, ""}, {38, ""}, {39, ""}, {40, "lv8"}, {41, ""}, {42, 
""}, {43, ""}, {44, ""}, {45, "lv9"}, {46, ""}, {47, ""}, {48, 
""}, {49, ""}, {50, "lv10"}};

Manipulate[
 ListPlot3D[
  Table[i + j RandomReal[{1, 5}], {i, 50}, {j, 15}][[window - 9 ;; window]],
  AxesLabel -> {"x", "y", "value"}, 
  Ticks -> {Automatic, tickLabels[[window - 9 ;; window]], Automatic}], 
  {window, 10, 50, 1}]
$\endgroup$

1 Answer 1

2
$\begingroup$

You need to specify the actual range of y coordinates using DataRange.

Manipulate[
 ListPlot3D[
  Table[i + j RandomReal[{1, 5}], {i, 50}, {j, 15}][[window - 9 ;; 
     window]], AxesLabel -> {"x", "y", "value"}, 
  DataRange -> {{0, 15}, {window - 9, window}}, 
  Ticks -> {Automatic, tickLabels[[window - 9 ;; window]], 
    Automatic}], {window, 10, 50, 1}]

enter image description here

As it stands, the default range for the y coordinates (Range[10]) is used in your original code.

Alternatively, you can use the form ListPlot3D[{{x1, y1, z1},{x2, y2, z2}, ...}] providing the three coordinates of each data point:

Manipulate[
 ListPlot3D[
  Join @@ Table[{j, i, i + j  RandomReal[{1, 5}]}, {i, 50}, {j, 
      15}][[window - 9 ;; window]],
  AxesLabel -> {"x", "y", "value"}, 
  Ticks -> {Automatic, tickLabels[[window - 9 ;; window]], 
    Automatic}], {window, 10, 50, 1}]
$\endgroup$
2
  • $\begingroup$ Many thanks, kguler. There are so many options that I don't even know what is possible. $\endgroup$
    – Edmund
    Sep 13, 2014 at 11:44
  • $\begingroup$ @Edmund, my pleasure. Thank you for the Accept. $\endgroup$
    – kglr
    Sep 13, 2014 at 11:52

Your Answer

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

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