0

I am creating a monte-carlo simulation to find the total fluorescence from a foil at a certain thickness and a certain angle.

If I have run the program for many thicknesses and many angles I will have a bunch of elements in a large array.

lets say its

store_array = [thickness,angle,photonscounted]

so at any value in the array it gives the thickness and the angle of the calculation performed, aswell as its result.

How do I plot a histogram where the axis are thickness and angle, and the colour value of the given coordinate is the photons counted by that combination?

2 Answers2

1

This sounds like a xy-scatter plot to me. In case this is the case, see my example (using some dummy values). Each of x, y and c are arrays corresponding to your thickness, angle, photon-count. If you want to use different colors, your can take another colormap from here or create your own.

import numpy as np
import matplotlib.pyplot as plt


fig, ax = plt.subplots()
N = 100
x = np.random.rand(N)            # generate dummy thickness values (0-1)
y = np.random.randint(5, 90, N)  # generate dummy angles (5-90)
c = np.array(x*y)                # dummy values for photon count

scatter = ax.scatter(x, y, c=c, cmap='viridis')
plt.xlabel('thickness')
plt.ylabel('angle')

plt.show()

resulting output

white
  • 601
  • 3
  • 8
  • Yes that's more in line with what I'm looking for! – ruairi shannon Nov 15 '21 at 13:53
  • Please remember to mark an [answer as accepted](https://stackoverflow.com/help/someone-answers). – white Nov 16 '21 at 09:27
  • You do want to make sure that the used colormap is perceptually uniform sequential, to avoid creating visual artifacts. See `cmocean` or `CMasher` for such colormaps. – 1313e Nov 30 '21 at 10:46
0

How do I plot a histogram where the axis are thickness and angle, and the colour value of the given coordinate is the photons counted by that combination?

Do you mean a three dimensional histogram?

Or a two dimensional scatter plot with a third dimension encoded by color?

In either case, humans perceive color in highly non-linear ways, compared to how we encode color values into software.

One should probably avoid the Rainbow Map, because although it promises the broadest possible range of color values to map your photonscounted to, people can't distinguish between numerically different, but perceptually similar colors, particularly in the green and yellow portions of the spectrum.

Heat maps, which range from red to green, fare better, except that the most common form of color blindness impedes discernment of red and green.

Grayscale may seem more accessible to all but the fully blind, except that your choice of background distorts the color encoding. If you choose a white background, white values for photonscounted may blend invisibly with the background while everything darker than 50% gray will seem black. Likewise, if you choose black, only lighter points will be visible, but compared to black, all will seem white. Gray mediates the issue, but while it highlights the extremes, blurs out the average.

Ben McKenneby
  • 481
  • 4
  • 15
  • Yes a two dimensional scatter plot with a third dimension encoded by colour is exactly what I was looking for, thank you very much! Those are some great notes on how to colorscale it aswell. As the main points I'm trying to show in my paper are the optimal values the Gray option you discussed seem best. Thanks! :-) – ruairi shannon Nov 15 '21 at 14:00
  • You might also consider glyph size or translucency to encode photonscounted. You should ^ white's answer. Looks like s/he did all of the work. :) – Ben McKenneby Nov 16 '21 at 22:42