Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank squares in output plots #137

Open
siqiwang55 opened this issue Mar 11, 2021 · 8 comments
Open

Blank squares in output plots #137

siqiwang55 opened this issue Mar 11, 2021 · 8 comments

Comments

@siqiwang55
Copy link

siqiwang55 commented Mar 11, 2021

Hi,
I tried running the codes provided in the tutorial, but instead of getting the same volcano plots as demonstrated in the tutorial, there are some blank squares in my output plots (attached). Anyone understand what the problem might be?

I'm using:
Python: 3.8
matplotlib: 3.3.4
numpy: 1.20.1
scipy: 1.6.0
mpmath: 1.2.1
ase: 3.21.1

pretty_production_rate.pdf
all_rates.pdf

@755452800
Copy link

755452800 commented Apr 15, 2021

I had the same issue with much larger blank squares. Have you fixed the problem?
image

@siqiwang55
Copy link
Author

I had the same issue with much larger blank squares. Have you fixed the problem?
image

Hi Steven,

I did find a way to temporarily solve this problem, but I don't know if it is the actual correct solution we should be using. Anyway, you can try modifying the following code in mkm_job.py:

from catmap import analyze
vm = analyze.VectorMap(model)
vm.plot_variable = 'rate' #tell the model which output to plot
vm.log_scale = True #rates should be plotted on a log-scale
vm.min = 1e-25 #minimum rate to plot
vm.max = 1e2 #maximum rate to plot
vm.plot(save='rate.pdf') #draw the plot and save it as "rate.pdf"

increase the vm.min value to 1e-20 or something larger, and the blank squares would disappear. Hope this works for you, and if you find another solution please let me know.

@755452800
Copy link

Hi Siqi,
I just read the history commits and find the solution to the colormap issue, simply add:

  from catmap import analyze
  vm = analyze.VectorMap(model)
  vm.plot_variable = 'rate' #tell the model which output to plot
  vm.log_scale = True #rates should be plotted on a log-scale
  vm.min = 1e-25 #minimum rate to plot
  vm.max = 1e2 #maximum rate to plot
+ vm.colormap = "jet"
  vm.plot(save='rate.pdf') #draw the plot and save it as "rate.pdf"

and the colormap will use the older version "jet" pattern, which in my sense is more beautiful.

@siqiwang55
Copy link
Author

Perfect, I'll try this out, thanks for letting me know! And here's my email address [email protected]
I'd be happy to have any further discussion regarding CatMap with you.

@GumiJiong
Copy link

GumiJiong commented Feb 15, 2022

I've found that this issue is caused by a data-structure transferring error in the function ReactionModel.map_to_array(), and some of the values are lower than your set vm.min (e.g. 1e-25) would be wrongly transferred to -1e-25, so the following np.log10() function would return a NaN, which leads to the blank in the output plot.

This numerical error can be fixed by adding the following code in row 272 of https://github.com/SUNCAT-Center/catmap/blob/master/catmap/analyze/analysis_base.py and reinstalling the package:

if self.log_scale and dim == 2:
    for i in range(0,len(maparray)): 
        for j in range(0,len(maparray[0])):
            for k in range(0,len(maparray[0][0])):
                if maparray[i][j][k] < 0:
                    maparray[i][j][k]=-1*maparray[i][j][k]
    maparray = np.log10(maparray)

@angelsu21
Copy link

angelsu21 commented Dec 7, 2022

I've found that this issue is caused by a data-structure transferring error in the function ReactionModel.map_to_array(), and some of the values are lower than your set vm.min (e.g. 1e-25) would be wrongly transferred to -1e-25, so the following np.log10() function would return a NaN, which leads to the blank in the output plot.

This numerical error can be fixed by adding the following code in row 272 of https://github.com/SUNCAT-Center/catmap/blob/master/catmap/analyze/analysis_base.py and reinstalling the package:

if self.log_scale and dim == 2:
    for i in range(0,len(maparray)): 
        for j in range(0,len(maparray[0])):
            for k in range(0,len(maparray[0][0])):
                if maparray[i][j][k] < 0:
                    maparray[i][j][k]=-1*maparray[i][j][k]
    maparray = np.log10(maparray)

Inspired by your comment, I found a mistake of model.py in data interpolation.

The following code in row 1292 of https://github.com/SUNCAT-Center/catmap/blob/master/catmap/model.py need to be adjusted。

It should be zi = np.exp(z_num) instead of zi = np.exp(z_num)*z_sign

@mhangaard
Copy link
Collaborator

mhangaard commented Dec 10, 2022

Hi Siqi, I just read the history commits and find the solution to the colormap issue, simply add:

  from catmap import analyze
  vm = analyze.VectorMap(model)
  vm.plot_variable = 'rate' #tell the model which output to plot
  vm.log_scale = True #rates should be plotted on a log-scale
  vm.min = 1e-25 #minimum rate to plot
  vm.max = 1e2 #maximum rate to plot
+ vm.colormap = "jet"
  vm.plot(save='rate.pdf') #draw the plot and save it as "rate.pdf"

and the colormap will use the older version "jet" pattern, which in my sense is more beautiful.

See more choices for colormaps here: https://matplotlib.org/stable/tutorials/colors/colormaps.html

Note that you should never use jet for anything. The reason is that brightness and contrast vary non-linearly, thus misrepresenting distance between values. It misrepresents values even worse if printed in black and white or viewed by a colorblind person.

I think the perceptually uniform sequential colormaps are best suited for volcano plots.

@755452800
Copy link

Hi Siqi, I just read the history commits and find the solution to the colormap issue, simply add:

  from catmap import analyze
  vm = analyze.VectorMap(model)
  vm.plot_variable = 'rate' #tell the model which output to plot
  vm.log_scale = True #rates should be plotted on a log-scale
  vm.min = 1e-25 #minimum rate to plot
  vm.max = 1e2 #maximum rate to plot
+ vm.colormap = "jet"
  vm.plot(save='rate.pdf') #draw the plot and save it as "rate.pdf"

and the colormap will use the older version "jet" pattern, which in my sense is more beautiful.

See more choices for colormaps here: https://matplotlib.org/stable/tutorials/colors/colormaps.html

Note that you should never use jet for anything. The reason is that brightness and contrast vary non-linearly, thus misrepresenting distance between values. It misrepresents values even worse if printed in black and white or viewed by a colorblind person.

I think the perceptually uniform sequential colormaps are best suited for volcano plots.

Thanks for your advice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants