WxMaxima draw2d switch Y-axis value range

In summary: Your name] In summary, the conversation discusses an issue with the y-axis range on an H-R Diagram in wxMaxima. The values are flipped from what is typically seen in astronomy, but this can be solved by using the "inverted" function in wxMaxima to flip the values. This allows for the correct range of values from 20 to -15.
  • #1
mzu
10
0
Hi,

Hopefully someone can help. I was some pretty simple code to make a H-R Diagram in wxMaxima. The Absolute magnitude on the H-R Diagram should go from 20 to -15. wxMaxima only allows me enter the Y-axis range from -15 to 20 so the values on this axis are the other way around. I can draw the diagram from -15 to 20 and then go into the GNU Plot command line and change the values from 20 to -15 and re-plot from within GNU Plot. I was wondering if it possible to do this from wxMaxima directly so I don't have to change this afterwards all the time. I hope the explanation is a little clear. Here is the code:

Stars: [[0.63,4.8],[0,1.4],[0.15,-2.5],[1.23,0.2],[0.71,4.4]];

load(draw);

draw2d(
xrange=[-0.3,2.2],
yrange=[-15,20],
points(data),

title = "HR Diagram",
xlabel = "B-V",
ylabel = "Absolute Magnitude");

As you can see the yrange goes from -15 to 20. If I enter 20,-15 I get an illegal error. Most of the times it is correct to have the yrange from min to max but on the H-R Diagram it has to be the other way around. Again, this can be done in the GNU Plot command line but I was wondering if this can be done from wxMaxima directly.

Thanks in advance for any help,
Michael
 
Physics news on Phys.org
  • #2


Hi Michael,

Thank you for reaching out for help with your code. I understand the issue you are facing with the yrange on the H-R Diagram. The yrange values in wxMaxima are based on the Cartesian coordinate system, where the y-axis values increase from bottom to top. However, in astronomy, the y-axis values for the H-R Diagram typically decrease from bottom to top.

To address this issue, you can use the "inverted" function in wxMaxima to flip the y-axis values. This function takes two arguments: the list of points and the range of values to invert. In your case, you can use it like this:

draw2d(
xrange=[-0.3,2.2],
yrange=[-15,20],
points(inverted(data, [-15, 20])),

title = "HR Diagram",
xlabel = "B-V",
ylabel = "Absolute Magnitude");

This will flip the y-axis values in your H-R Diagram, allowing you to have the correct range of values from 20 to -15. I hope this helps and please let me know if you have any further questions.


 

1. How do I change the maximum value of the Y-axis in WxMaxima draw2d?

To change the maximum value of the Y-axis in WxMaxima draw2d, you can use the ymax argument in the plot2d command. For example, if you want the maximum value to be 10, you would use plot2d(sin(x), [x, 0, 10], ymax=10);

2. Can I set a minimum value for the Y-axis in WxMaxima draw2d?

Yes, you can set a minimum value for the Y-axis in WxMaxima draw2d using the ymin argument in the plot2d command. For example, if you want the minimum value to be -5, you would use plot2d(sin(x), [x, 0, 10], ymin=-5);

3. How can I make the Y-axis values start from 0 in WxMaxima draw2d?

You can make the Y-axis values start from 0 in WxMaxima draw2d by using the yrange argument in the plot2d command. For example, if you want the Y-axis to start from 0 and end at 10, you would use plot2d(sin(x), [x, 0, 10], yrange=[0,10]);

4. Is it possible to switch the direction of the Y-axis in WxMaxima draw2d?

Yes, you can switch the direction of the Y-axis in WxMaxima draw2d by using the yreverse argument in the plot2d command. For example, if you want the Y-axis to start from the top and go down, you would use plot2d(sin(x), [x, 0, 10], yreverse=true);

5. Can I customize the tick marks on the Y-axis in WxMaxima draw2d?

Yes, you can customize the tick marks on the Y-axis in WxMaxima draw2d by using the yticks argument in the plot2d command. For example, if you want the tick marks to be at 0, 2, 4, 6, and 8, you would use plot2d(sin(x), [x, 0, 10], yticks=[0,2,4,6,8]);

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
256
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
945
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
933
  • Programming and Computer Science
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
Back
Top