Matplotlib-plotting-based on different condions from different maps

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Matplotlib-plotting-based on different condions from different maps

matplotlib - users mailing list
Dear all,
I need some help with regards to colormaps, I am new to python and unsure how to go about it.

I have three spatial correlation maps, lets call the A(72x144), B(72X144) and C(72x144) and each one of these are made of of values from -1 to 1.

Now I want to generate one single colomap form these based on the following conditions,

For regions where A > 0.5, B > 0.5 and C > 0.5, make those regions red on the new color map, for regions where A>0.5, B = 0 and C = 0 also make those regions Blue.

In a coding format I want something like this
For in range(x):
  for J in range(y):
     if A(i,j) >0 & if B(i,J) > 0.5 & if C>0.5:
       then colormap = Reds.
This is the general idea I have but dont know how to write this and make it actually work with my code.
I am open to anwer further questions and I would be most grateful for your help.

Thanks
Adam.




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

Re: Matplotlib-plotting-based on different condions from different maps

Jody Klymak
Hi Adam,

Have a look at `BoundaryNorm` i.e.: https://matplotlib.org/tutorials/colors/colormapnorms.html#discrete-bounds.  Feel free to ask further if you have issues with that.  

However, for your case, you may just want to use pcolormesh and just set the color argument directly.  

Cheers,   Jody

> On May 2, 2019, at  23:53 PM, Mustapha Adamu via Matplotlib-users <[hidden email]> wrote:
>
> Dear all,
> I need some help with regards to colormaps, I am new to python and unsure how to go about it.
>
> I have three spatial correlation maps, lets call the A(72x144), B(72X144) and C(72x144) and each one of these are made of of values from -1 to 1.
>
> Now I want to generate one single colomap form these based on the following conditions,
>
> For regions where A > 0.5, B > 0.5 and C > 0.5, make those regions red on the new color map, for regions where A>0.5, B = 0 and C = 0 also make those regions Blue.
>
> In a coding format I want something like this
> For in range(x):
>   for J in range(y):
>      if A(i,j) >0 & if B(i,J) > 0.5 & if C>0.5:
>        then colormap = Reds.
> This is the general idea I have but dont know how to write this and make it actually work with my code.
> I am open to anwer further questions and I would be most grateful for your help.
>
> Thanks
> Adam.
>
>
>
> _______________________________________________
> 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