In Meteorology we use a diagram known as a Skew-T/Log-P. In short, the x-coordinate is temperature and the y-coordinate is pressure. The temperature lines (x-coordinate) are skewed such that "vertical lines" (in reality, lines of constant X) are skewed to the right by some angle. Pressure (y-coordinate) is plotted on a log scale. I've attached a sample image of a Skew-T/Log-P Diagram.
A friend of mine and I worked this past winter to add the ability to plot Skew-T/Log-P diagrams in Matplotlib. (It's currently sitting in a pull request that I need to finish.) However, MPL is too slow for a lot of what I want to do down the road, so I decided to give pyqtgraph a go. Unfortunately, after two days, I cannot get the skewed x-axis to work.My question: is it even possible to generate a skewed coordinate system?Below is a sample script I put together to try to even get something skewed. It appears that temperature (red line) is different, but I'm not sure how/why, nor how to recreate the figure attached.
Thanks for any help/advice.
- Will the user be able to scale / pan the plot interactively?
- How are the curved grid lines defined?
- Can you send a test script that would serve to demonstrate whether the transformation is working correctly? (perhaps by showing a matplotlib and pyqtgraph plot together?)
As an example, I have attached a modification of your script that does the following:- Logarithmic scaling on y-axis- Horizontal grid lines provided by the plot- Static set of vertical grid lines- Grid lines and t/p plot are both children of a group with a shear transformation
Note that the values on the x-axis do not take into account the shear transformation; a little more effort would be required to make this correction. Also, the shear value that goes into the group transformation is arbitrary, since we would have to take into account the x/y scale factors in order to comput the correct factor for a 30 degree skew.
Now, to address some of your specific questions:- Will the user be able to scale / pan the plot interactively?
Eventually I would like this. I've noticed that the pyqtgraph objects have all of this hooked up (or am I mistaken?) on the front end, which is one reason why I thought about staying at the pyqtgraph level rather than just staying down in the Qt primitives.
- How are the curved grid lines defined?I am not entirely sure which curved lines you are talking about? The ones that start from bottom right and go to the upper left? These are actually straight lines (lines of constant potential temperature [known as dry adiabats in Skew-T lingo]). They appear curved as a result of the log scaling. There are actually curved lines that go from the bottom right to the upper left (not shown in the original image). These are known as moist adiabatic, and they are computed through a helper function that iterates "up through the atmosphere" to calculate what that curve is. Ultimately, I'm just plotting pres and temp for all the curves.
As an example, I have attached a modification of your script that does the following:- Logarithmic scaling on y-axis- Horizontal grid lines provided by the plot- Static set of vertical grid lines- Grid lines and t/p plot are both children of a group with a shear transformationThanks! This looks great, at least for the "grid lines". The temperature curve still doesn't look like it is skewed properly. When the temperature curve is skewed correctly, it should be more vertical than horizontal.
Note that the values on the x-axis do not take into account the shear transformation; a little more effort would be required to make this correction. Also, the shear value that goes into the group transformation is arbitrary, since we would have to take into account the x/y scale factors in order to comput the correct factor for a 30 degree skew.This is great to know! In previous versions I tried to emulate the coordinate transformations we applied to the Matplotlib code. However, with Qt/pyqtgraph I could not figure out what the units in the shear needed to be.I guess ultimately the first thing I need to decide is to try and wrap this transformation into the underlying QT architecture (similar to what we've done with Matplotlib) or write a stand-alone mapping function that sits outside the plotting function and is just called manually on everything (a la the Tkinter example).