I've been trying to solve this problem for a while, but I'm still struggling, as the Flopy documentation doesn't cover this issue, and I don't have an in depth understanding of pcolormesh() and exactly how it is used by Flopy. I'm trying to create a 2D concentration graph of a contaminant plume. The values of concentration range from 0 to 5000 (mg/l). I would like the lowest concentration, 0, to be represented by white, so I chose the binary colormap for this purpose. I don't know if there is a colormap or method which could show the data better. Since there are so many concentration values, I've found that using a symmetrical log (norm='symlog') helps show the data better. However, when I use this method it ruins the colorbar. How do I make the values on the colorbar symmetrical?
So in short, I want the second graph to have the colorbar on the first graph, with a clearly defined min and max value. How do I do this? Also, is there a better colormap to use which has its lowest value set to white?
Graph 1, linear scale Graph 2, symlog scale
Below is the code used to produce each graph. For the first graph norm=norm, and for the second norm='symlog'. I don't know why using the Normalize() method produces a colobar with a defined min and max whereas norm='linear' doesn't, despite the concentration being identical.
plt.figure(figsize=(10,10))
ucnobj = bf.UcnFile('init_plume_ED.UCN')
times = ucnobj.get_times()
conc = ucnobj.get_data(totim=times[-1])
modelmap = flopy.plot.PlotMapView(model=mf, layer=13, extent=(725,925,100,220))
norm = Normalize(vmin=0, vmax=5000)
cs = modelmap.plot_array(conc, cmap='binary', norm='symlog')
cbar = plt.colorbar(cs,shrink=0.2)
plt.title('Initial phenol plume concentration (symlog scale)
The plot_array() function uses kwargs from pcolormesh().
I've tried several methods, like defining the ticks and the min and max tick values; it still doesn't display the values correctly.
Edit: this is what happens when I use norm='symlog
and use custom tick values and labels as suggested in the first comment.
EDIT: I fixed the issue. The problem was that I had negative values (MT3D sets concentration values in dry cells to -1e30) and many small values between 0 and 1. The log scale was preferentially showing the values between 0 and 1; symlog was showing the concentration distribution I wanted (0 to 5000), but its respective colorbar was showing other values. When I used 'ma.masked_equal(concentration_array,-1e30)' it stopped displaying the negative values on the colorbar and started showing the prescribed values.