Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is the plot I want to change:

B1spins = ListVectorPlot[
               Table[{{m, n}, {P1[[1, m, n]], P1[[3, m, n]]}}, {m, 1, 41}, {n, 1, 41}],  
               VectorColorFunction -> Function[Hue[Log[#5]/3]], ImageSize -> 425,
               VectorColorFunctionScaling -> False, VectorScale -> Small, 
               VectorPoints -> 35,  AxesLabel -> {qx, qy},
               LabelStyle -> Directive[Bold, 20, FontFamily -> "Helvetica"]
 ]

The current x and y axes show values from 1 to 41, as expected for a 41x41 matrix. I want to change them to read from -1.0 to 0.1. I have used DataRange for this before, generally with ListDensityPlot and ListPlot.

However, it refuses to work with ListVectorPlot. It simply shrinks the plotting range, like PlotRange does.

I tried creating custom tick marks as shown in How can I set the range of x-axis?. But the PlotRange command again refuses to work. It simply shrinks the domain of plotting.

What do I do?

share|improve this question

closed as off-topic by Kuba, m_goldberg, Artes, Yves Klett, Jens Jul 23 '13 at 5:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Kuba, m_goldberg, Artes, Yves Klett, Jens
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Welcome to mathematica.SE, please post self consistent (there is no P1 definition) code and next time try to focus more on formatting your question. And referring to it - DataRange seems to be what you need and without P1 I do not know how to help you.. –  Kuba Jul 19 '13 at 15:54
add comment

1 Answer 1

Omit the explicit specification of the coordinates, {m, n}, and just pass the vectors to ListVectorPlot. Then the DataRange option will work as desired.

SeedRandom[1];
P1 = RandomReal[1, {3, 41, 41}];
B1spins = 
 ListVectorPlot[
  Table[(*{{m, n},*){P1[[1, m, n]], P1[[3, m, n]]}(*}*), {m, 1, 41}, {n, 1, 41}], 
  DataRange -> {{-1., 0.1}, {-1., 0.1}}, 
  VectorColorFunction -> Function[Hue[Log[#5]/3]], ImageSize -> 425, 
  VectorColorFunctionScaling -> False, VectorScale -> Small, 
  VectorPoints -> 35, AxesLabel -> {qx, qy}, 
  LabelStyle -> Directive[Bold, 20, FontFamily -> "Helvetica"]]

Mathematica graphics

Somewhat more efficiently:

ListVectorPlot[Transpose[P1[[{1, 3}, All, All]], {3, 1, 2}], 
 DataRange -> {{-1., 0.1}, {-1., 0.1}}, 
 VectorColorFunction -> Function[Hue[Log[#5]/3]], ImageSize -> 425, 
 VectorColorFunctionScaling -> False, VectorScale -> Small, 
 VectorPoints -> 35, AxesLabel -> {qx, qy}, 
 LabelStyle -> Directive[Bold, 20, FontFamily -> "Helvetica"]]

or equivalently use

Transpose[{P1[[1, All, All]], P1[[3, All, All]]}, {3, 1, 2}]

as the data for ListVectorPlot.

share|improve this answer
add comment

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