Dear all, I'm trying to perform a scatter plot with color with an associated color bar. I would like the colorbar to have string values rather than numerical values, as I'm comparing two different data sets each one with different colorvalues (but in any case between a maximum and minimum values). Here the code I'm using
import matplotlib.pyplot as plt
import numpy as np
from numpy import *
from matplotlib import rc
import pylab
from pylab import *
from matplotlib import mpl
data = np.loadtxt('deltaBinned.txt')
data2 = np.loadtxt('deltaHalphaBinned.txt')
fig=plt.figure()
fig.subplots_adjust(bottom=0.1)
ax=fig.add_subplot(111)
plt.xlabel(r'$\partial \Delta/\partial\Phi[$mm$/^{\circ}]$',fontsize=16)
plt.ylabel(r'$\Delta$ [mm]',fontsize=16)
plt.scatter(data[:,0],data[:,1],marker='o',c=data[:,3],s=data[:,3]*1500,cmap=cm.Spectral,vmin=min(data[:,3]),vmax=max(data[:,3]))
plt.scatter(data2[:,0],data2[:,1],marker='^',c=data2[:,2],s=data2[:,2]*500,cmap=cm.Spectral,vmin=min(data2[:,2]),vmax=max(data2[:,2]))
cbar=plt.colorbar(ticks=[min(data2[:,2]),max(data2[:,2])])
cbar.set_ticks(['Low','High'])
cbar.set_label(r'PdF')
plt.show()
Unfortunately it does not work as cbar.set_ticks does not accept string values. I've read the ling http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html but Iwas not able to adapt it to my case. I apologize if the question is simple but I'm just at the beginning of python programming Nicola.