6 messages
Open this post in threaded view
|

 Hii FolksI have an array with dimension (plev: 7, lat: 81). I was trying to draw streamline plot for Omega and V wind [Hadley cell].  I am facing some error with plt.streamplot as it says that both the dimension should be of equal size (i.e. N * N ). Is there any other way to create a streamline plot for the data having unequal values along both the dimensions?I seek help of the community in this regard.I hope I framed my question correctly.  Please let me know if I need to clarify more details.Thank you-- ========================================Dhirendra KumarPhD StudentSchool of Environmental Sciences, JNUNew Delhi (India)Contact: +91 9910778043Alternate email: [hidden email]========================================= _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users
Open this post in threaded view
|

 Hi Kumar, Could provided a snippet with a (standalone) minimal working example of what you have tried ? AFAICT, looking at https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.streamplot.html it does not look like X and Y arrays of coordinates have to be of equal length (but the velocity arrays U and V should have relevant dimensions relative to X and Y). Best regards, Adrien On April 16, 2019 11:05:01 PM GMT+02:00, Dhirendra Kumar <[hidden email]> wrote: >Hii Folks > >I have an array with dimension (plev: 7, lat: 81). I was trying to draw >streamline plot for Omega and V wind [Hadley cell].  I am facing some >error >with* plt.streamplot* as it says that both the dimension should be of >equal >size (i.e. N * N ). Is there any other way to create a streamline plot >for >the data having unequal values along both the dimensions? > >I seek help of the community in this regard. > >I hope I framed my question correctly.  Please let me know if I need to >clarify more details. > >Thank you -- Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users
Open this post in threaded view
|

 Kumar, FWIW, based on the [streamplot example](https://matplotlib.org/gallery/images_contours_and_fields/plot_streamplot.html) in the gallery, the following snippet seems to be working just fine (with Matplotlib 3.0.1) “even though” the amount of X and Y coordinate values is (Nx, Ny) = (100, 50). ```python import numpy as np import matplotlib.pyplot as plt # Dummy data w = 3 Nx, Ny = 100, 50 Y, X = np.mgrid[-w:w:50j, -w:w:100j] U = -1 - X**2 + Y V = 1 + X - Y**2 fig, ax = plt.subplots() ax.streamplot(X, Y, U, V) ax.set_title(f"{Nx/Ny:g}× more points along X than Y") ``` Best, Adrien Le 17/04/2019 à 08:14, Adrien VINCENT a écrit : > Hi Kumar, > > Could provided a snippet with a (standalone) minimal working example of what you have tried ? > > AFAICT, looking at https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.streamplot.html it does not look like X and Y arrays of coordinates have to be of equal length (but the velocity arrays U and V should have relevant dimensions relative to X and Y). > > Best regards, > Adrien > > > > On April 16, 2019 11:05:01 PM GMT+02:00, Dhirendra Kumar <[hidden email]> wrote: >> Hii Folks >> >> I have an array with dimension (plev: 7, lat: 81). I was trying to draw >> streamline plot for Omega and V wind [Hadley cell].  I am facing some >> error >> with* plt.streamplot* as it says that both the dimension should be of >> equal >> size (i.e. N * N ). Is there any other way to create a streamline plot >> for >> the data having unequal values along both the dimensions? >> >> I seek help of the community in this regard. >> >> I hope I framed my question correctly.  Please let me know if I need to >> clarify more details. >> >> Thank you > _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users streamplot_example_for_kumar.png (115K) Download Attachment
Open this post in threaded view
|

 Hii AdrienThanks for the reply. I have tried your example and could replicate it. But in case of my script I have two variables:V and Omega having sizes:([('plev', 12), ('lat', 81)]))([('plev', 12), ('lat', 81)]))Plev has to be plotted on y axis and lat has to be plotted on x axis. I am using following lines to create the plot:plt.subplot(331)plt.contourf(CC_W_CON11,cmap='RdBu')plt.streamplot(X, Y, Omega,  V)This gives me an error as:  File "/opt/apps/ANACONDA/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2951, in streamplot    if data is not None else {}))  File "/opt/apps/ANACONDA/lib/python3.7/site-packages/matplotlib/__init__.py", line 1810, in inner    return func(ax, *args, **kwargs)  File "/opt/apps/ANACONDA/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 4882, in streamplot    integration_direction=integration_direction)  File "/opt/apps/ANACONDA/lib/python3.7/site-packages/matplotlib/streamplot.py", line 79, in streamplot    grid = Grid(x, y)  File "/opt/apps/ANACONDA/lib/python3.7/site-packages/matplotlib/streamplot.py", line 311, in __init__    raise ValueError("The rows of 'x' must be equal")ValueError: The rows of 'x' must be equalCould you please look if there is any mistake ??ThanksOn Wed, Apr 17, 2019 at 1:27 PM [hidden email] <[hidden email]> wrote:Kumar, FWIW, based on the [streamplot example](https://matplotlib.org/gallery/images_contours_and_fields/plot_streamplot.html) in the gallery, the following snippet seems to be working just fine (with Matplotlib 3.0.1) “even though” the amount of X and Y coordinate values is (Nx, Ny) = (100, 50). ```python import numpy as np import matplotlib.pyplot as plt # Dummy data w = 3 Nx, Ny = 100, 50 Y, X = np.mgrid[-w:w:50j, -w:w:100j] U = -1 - X**2 + Y V = 1 + X - Y**2 fig, ax = plt.subplots() ax.streamplot(X, Y, U, V) ax.set_title(f"{Nx/Ny:g}× more points along X than Y") ``` Best, Adrien Le 17/04/2019 à 08:14, Adrien VINCENT a écrit : > Hi Kumar, > > Could provided a snippet with a (standalone) minimal working example of what you have tried ? > > AFAICT, looking at https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.streamplot.html it does not look like X and Y arrays of coordinates have to be of equal length (but the velocity arrays U and V should have relevant dimensions relative to X and Y). > > Best regards, > Adrien > > > > On April 16, 2019 11:05:01 PM GMT+02:00, Dhirendra Kumar <[hidden email]> wrote: >> Hii Folks >> >> I have an array with dimension (plev: 7, lat: 81). I was trying to draw >> streamline plot for Omega and V wind [Hadley cell].  I am facing some >> error >> with* plt.streamplot* as it says that both the dimension should be of >> equal >> size (i.e. N * N ). Is there any other way to create a streamline plot >> for >> the data having unequal values along both the dimensions? >> >> I seek help of the community in this regard. >> >> I hope I framed my question correctly.  Please let me know if I need to >> clarify more details. >> >> Thank you > -- ========================================Dhirendra KumarPhD StudentSchool of Environmental Sciences, JNUNew Delhi (India)Contact: +91 9910778043Alternate email: [hidden email]========================================= _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users