non linear color range for z-axis

101 Views Asked by At

thank you for your help!

I am plotting a contour plot to represent the sensitivity of a detector in a given range. Most of the data I have are below the mean value so most of my plot is in the blue range when I plot.

EDIT I have found my mistake. I should have taken the log values for the Z instead of normalizing them. Now, the plot looks better. Please look at the before and after log plots. But is there a way to improve the plot as more data are located in the 900000 to 1350000 range. If I limit the range then the data above them are lost.

Also I want to know if there is any code that can directly take the log scale for Z axis?

Please let me know if you want more details !

data_ggf.csv

    ##      importing libraries     ##

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as ticker

##  read the csv files   ##
df1 = pd.read_csv (r'D:\sys_files\Downloads\data_ggf.csv')

##  declare the variables   ##
x = np.arange(-50,75,25)
y = df1[['Y']]
[X, Y] = np.meshgrid(x, y)
Z = df1[['x100','x75','x0','x25','x50']]
z_n = Z.to_numpy()

##  define the functions    ##
Z_log = np.log10(z_n)

fig, ax = plt.subplots()
im = ax.contourf(X,Y,Z_log, 1000, cmap='jet', extend='both')

##  below are plot settings     ##
def myfmt(x, pos):
    return '{0:.1f}'.format((10**x))


cbar = plt.colorbar(im, format=ticker.FuncFormatter(myfmt))
cbar.ax.set_ylabel('neutron neutron per second', rotation=270)
plt.xticks(np.arange(-50, 50, 10))
plt.yticks(np.arange(10, 200, 20))
plt.axis([-50, 50, 10, 200])
plt.xlabel('Distance b/w Detectors in cm')
plt.ylabel('Distance from Ground in cm')
plt.title('neutron neutron sensitivity map for central plane')
plt.show()

Before Log Plot After Log Plot

0

There are 0 best solutions below