I have a set of data that represents thermocouple values at multiple points over time. Using Chaco I have managed to plot a heatmap of the thermocouple locations, with a slider that lets me pick the time step I want displayed. The purpose of this is to compare how the dataset changes over time.
The problem I am having is that the colormap scale changes based on the max and min values shown on screen, but I would like the colormap scale to stay fixed with a predetermined min and max. Is there an easy way to do this using Chaco and Traits? I have looked through the Chaco documentation, but none of the examples I have found cover this situation.
For simplicity, here is a pared down copy of my code. I have replaced my data with a generated dataset of the same shape, with the same value min and max.
import numpy as np
from enable.api import *
from chaco.shell import *
from traits.api import *
from traitsui.api import *
from chaco.api import *
from chaco.tools.api import *
## Random Data
data11 = np.ones([3,5,100])
print data11.shape
for i in range(3):
for j in range(5):
for k in range(100):
data11[i,j,k] = np.random.random_integers(1100)
class heatplots(HasTraits):
plot = Instance(Plot)
time = Range(1,99)
traits_view = View(Item('time'),
Item('plot', editor=ComponentEditor()),
width=1000, height=600, resizable=True, title='heatmap')
def datamaker(self): ## Setting the data time
t = self.time
## Defining the data picker sources
self.data = data11[...,...,t]
def heatplotter(self): ##Making the Plots
## The first heatmap
self.plotdata1 = ArrayPlotData(hm1 = self.data)
plot1 = Plot(self.plotdata1)
plot1.img_plot("hm1", colormap=hot)
self.plot = plot1
#_heatplotter()
@on_trait_change('time')
def _new_time(self):
self.datamaker()
self.heatplotter()
def start(self):
self._new_time()
self.configure_traits()
thing = heatplots()
thing.start()
If some of my formating seems odd or round-about its probably because my complete plot includes a datapicker where I can pick between data sets, and it has 2 heatmaps side-by-side in an HPlotContainer. I have removed that because it is not relevant to my question.
Thank you for your time.