Skip to content
Advertisement

Matplotlib with variable upper limit

I need to contourplot one huge expression which is:

JavaScript

which is not so much relevant here.

Usually the task is trivial and can be done this way:

JavaScript

That all in common yields enter image description here

which is okay, but I have an issue I cannot handle.

The problem is that I need to plot it assuming that my y is not a simple array and the upperlimit is variable and must obey

JavaScript

In that case the result has to be

enter image description here

I do not know how to achieve this. So, how to contourplot with variable upper limit? I hope I stated my problem clear.

Any help will be greatly appreciated!

Thank you very much in advance!

Advertisement

Answer

You could use a masked array in order to mask AA value where a specific condition is met, in your case y > 0.1*cos(x).
So, from AA you can get:

JavaScript

And then you can plot it:

JavaScript

enter image description here

As a check you can also plot the specific threshold:

JavaScript

enter image description here

Complete Code

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement