Hello all,
Does anyone know how to reverse y-axis in wxMathplot? Currently, my Y-Axis starts from 0 at the bottom and goes up to the max value (for example 100) on the top. Is there a function or method to make the Y-Axis to start at the max value (100) from the bottom and go up to 0 on the top?
I attached a picture for reference.
Thank you!
periscopewxyun
Reverse Y-Axis in wxMathplot
-
- In need of some credit
- Posts: 5
- Joined: Sat Dec 16, 2017 6:59 am
Reverse Y-Axis in wxMathplot
- Attachments
-
- Reversed_Y_axis.png (44.67 KiB) Viewed 1515 times
-
- In need of some credit
- Posts: 5
- Joined: Sat Dec 16, 2017 6:59 am
Re: Reverse Y-Axis in wxMathplot
rando,
Thank you for your reply. I will consider other options.
Regards,
periscopewxyun
Thank you for your reply. I will consider other options.
Regards,
periscopewxyun
Re: Reverse Y-Axis in wxMathplot
I also need such feature.
I just tried to modify its source code by adding some function like:
In the void mpWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
But it does not work.
I also try to add some function like:
But it does not work either.
I just tried to modify its source code by adding some function like:
Code: Select all
SetAxisOrientation(true, false);
But it does not work.
I also try to add some function like:
Code: Select all
SetUserScale (1.0, -1.0)
Re: Reverse Y-Axis in wxMathplot
I try to use the solution in this thread: SetAxisOrientation does not work on wxBufferedPaintDC, but only on wxPaintDC
The SetAxisOrientation works, but the wxMathplot's source are hard to modify because it natively assume that the X axis is from left to right, and the Y axis is from bottom to top.
For example, in wxMathplot.h there are some code like below:
You see the x and y coordinates are handled differently.
I can simply change the SetAxisOrientation, but I need to change those codes too, and there are other codes I have to change.
So, I think create a custom mpScaleY is the correct way to go.
The SetAxisOrientation works, but the wxMathplot's source are hard to modify because it natively assume that the X axis is from left to right, and the Y axis is from bottom to top.
For example, in wxMathplot.h there are some code like below:
Code: Select all
/** Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
* @sa p2y,x2p,y2p */
// double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
inline double p2x(wxCoord pixelCoordX ) { return m_posX + pixelCoordX/m_scaleX; }
/** Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
* @sa p2x,x2p,y2p */
// double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
inline double p2y(wxCoord pixelCoordY ) { return m_posY - pixelCoordY/m_scaleY; }
/** Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
* @sa p2x,p2y,y2p */
// wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
inline wxCoord x2p(double x) { return (wxCoord) ( (x-m_posX) * m_scaleX); }
/** Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
* @sa p2x,p2y,x2p */
// wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
inline wxCoord y2p(double y) { return (wxCoord) ( (m_posY-y) * m_scaleY); }
I can simply change the SetAxisOrientation, but I need to change those codes too, and there are other codes I have to change.
So, I think create a custom mpScaleY is the correct way to go.