Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Xi Shen
Hi,

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html says the contour function accept a vector parameter V which must be in increasing value. But the contour function in MATLAB does not have this restriction.

I understand the underlining implementation of these two functions could be very different. I want to understand what is the purpose of this restriction, and if it possible to create a contour image the same as MATLAB does by using contour with V = [0 0]?


Regards,
David


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Benjamin Root
Probably because nobody noticed that discrepancy before. I'd imagine it would be fairly simple to apply a sort to the list of values within the function itself. The underlying contouring implementation assumes a monotonically increasing set of contour levels, and I would imagine that MATLAB's version does too -- just that they sort the contour levels for you.

At the moment, I don't see any reason why we couldn't do that, too.

Cheers!
Ben Root


On Wed, Aug 16, 2017 at 8:33 AM, Xi Shen <[hidden email]> wrote:
Hi,

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html says the contour function accept a vector parameter V which must be in increasing value. But the contour function in MATLAB does not have this restriction.

I understand the underlining implementation of these two functions could be very different. I want to understand what is the purpose of this restriction, and if it possible to create a contour image the same as MATLAB does by using contour with V = [0 0]?


Regards,
David


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Jody Klymak
In reply to this post by Xi Shen

Hi David,

I’ve definitely run into this, to my annoyance.

Do you think you can open an issue on GitHub? If you don’t want to, I’m happy to do it.

With respect to one contour at zero, its easier than Matlab:

ax.contour(X, np.array([0.]))

works for me…

Cheers,

On 16 Aug 2017, at 5:33, Xi Shen wrote:

Hi,

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html says the contour function accept a vector parameter V which must be in increasing value. But the contour function in MATLAB does not have this restriction.

I understand the underlining implementation of these two functions could be very different. I want to understand what is the purpose of this restriction, and if it possible to create a contour image the same as MATLAB does by using contour with V = [0 0]?


Regards,
David

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Xi Shen
Hi Jody,

I confirm that giving V = [0] to contour function in matplotlib gives me the same image as using V = [0 0] in MATLAB.

Do you think it is a bug in matplotlib, or it is just a conscious design decision? I do not have much knowledge of math behind this, so for me it is just a restriction on parameter values.


Thanks,
David
 

On Thu, Aug 17, 2017 at 12:48 AM Jody Klymak <[hidden email]> wrote:

Hi David,

I’ve definitely run into this, to my annoyance.

Do you think you can open an issue on GitHub? If you don’t want to, I’m happy to do it.

With respect to one contour at zero, its easier than Matlab:

ax.contour(X, np.array([0.]))

works for me…

Cheers,

On 16 Aug 2017, at 5:33, Xi Shen wrote:

Hi,

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html says the contour function accept a vector parameter V which must be in increasing value. But the contour function in MATLAB does not have this restriction.

I understand the underlining implementation of these two functions could be very different. I want to understand what is the purpose of this restriction, and if it possible to create a contour image the same as MATLAB does by using contour with V = [0 0]?


Regards,
David

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why the V parameter in matplotlib.axes.Axes.contour must be increasing?

Jody Klymak

I opened a pull request to change it, but we need to test a couple of things…

https://github.com/matplotlib/matplotlib/pull/9047

Cheers, Jody

On 16 Aug 2017, at 19:06, Xi Shen wrote:

Hi Jody,

I confirm that giving V = [0] to contour function in matplotlib gives me the same image as using V = [0 0] in MATLAB.

Do you think it is a bug in matplotlib, or it is just a conscious design decision? I do not have much knowledge of math behind this, so for me it is just a restriction on parameter values.


Thanks,
David
 

On Thu, Aug 17, 2017 at 12:48 AM Jody Klymak <[hidden email]> wrote:

Hi David,

I’ve definitely run into this, to my annoyance.

Do you think you can open an issue on GitHub? If you don’t want to, I’m happy to do it.

With respect to one contour at zero, its easier than Matlab:

ax.contour(X, np.array([0.]))

works for me…

Cheers,

On 16 Aug 2017, at 5:33, Xi Shen wrote:

Hi,

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.contour.html says the contour function accept a vector parameter V which must be in increasing value. But the contour function in MATLAB does not have this restriction.

I understand the underlining implementation of these two functions could be very different. I want to understand what is the purpose of this restriction, and if it possible to create a contour image the same as MATLAB does by using contour with V = [0 0]?


Regards,
David

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users