Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all jet color map use in examples with viridis #557

Merged
merged 2 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/demo/advanced/cmap_variable_sized_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Chaco imports
from chaco.api import ArrayPlotData, Plot, ColormappedScatterPlot, \
LinearMapper, ArrayDataSource, jet, DataRange1D
LinearMapper, ArrayDataSource, viridis, DataRange1D
from chaco.tools.api import PanTool, ZoomTool

#===============================================================================
Expand Down Expand Up @@ -61,7 +61,7 @@ def _create_plot_component():
index=index_ds,
value=value_ds,
color_data=color_ds,
color_mapper=jet(range=DataRange1D(low=0.0, high=1.0)),
color_mapper=viridis(range=DataRange1D(low=0.0, high=1.0)),
fill_alpha=0.4,
index_mapper = imapper,
value_mapper = vmapper,
Expand Down
11 changes: 2 additions & 9 deletions examples/demo/advanced/data_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class PlotFrame(DemoFrame):
# Private Traits
#---------------------------------------------------------------------------

_cmap = Trait(jet, Callable)
_cmap = Trait(viridis, Callable)

def _index_callback(self, tool, x_index, y_index):
plane = tool.token
Expand Down Expand Up @@ -226,15 +226,8 @@ def _wheel_callback(self, tool, wheelamt):

def _create_window(self):
# Create the model
#try:
# self.model = model = BrainModel()
# cmap = bone
#except SystemExit:
# sys.exit()
#except:
# print "Unable to load BrainModel, using generated data cube."
self.model = model = Model()
cmap = jet
cmap = viridis
self._update_model(cmap)

datacube = self.colorcube
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/advanced/scalar_image_function_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class PlotUI(HasTraits):
_image_index = Instance(GridDataSource)
_image_value = Instance(ImageData)

_cmap = Trait(default_colormaps.jet, Callable)
_cmap = Trait(default_colormaps.viridis, Callable)

#---------------------------------------------------------------------------
# Public View interface
Expand Down Expand Up @@ -542,7 +542,7 @@ def main(argv=None):
parser = OptionParser(usage=usage, version="%prog 1.0")

parser.add_option("-c", "--colormap",
action="store", type="string", dest="colormap", default="jet",
action="store", type="string", dest="colormap", default="viridis",
metavar="CMAP", help="choose a default colormapper")

parser.add_option("-n", "--nlevels",
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/advanced/scalar_image_function_inspector_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class PlotUI(HasTraits):
_image_index = Instance(GridDataSource)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example seems to be broken. When I run the example, I see the following error. This doesn't need to be fixed in this PR - but an issue (if one doesn't exist already) would be nice

python scalar_image_function_inspector_old.py
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\qt4\base_window.py", line 213, in paintEvent
    self.handler.paintEvent(event)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\qt4\base_window.py", line 65, in paintEvent
    self._enable_window._paint(event)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\abstract_window.py", line 471, in _paint
    self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\component.py", line 427, in draw
    self._draw(gc, view_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\component.py", line 779, in _draw
    self._dispatch_draw(layer, gc, view_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\container.py", line 273, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\container.py", line 271, in _dispatch_draw
    component._draw(gc, new_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\component.py", line 769, in _draw
    self._dispatch_draw(layer, bb, view_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\container.py", line 273, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\enable\component.py", line 799, in _dispatch_draw
    handler(gc, view_bounds, mode)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\chaco\base_2d_plot.py", line 204, in _draw_image
    self._render(gc)
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\chaco\contour_poly_plot.py", line 46, in _render
    self._update_polys()
  File "C:\Users\rporuri\.edm\envs\chaco-test-3.6-pyqt5\lib\site-packages\chaco\contour_poly_plot.py", line 86, in _update_polys
    c = Cntr(xg, yg, data, ~mask)
ValueError: Arguments x, y, z, mask (if present) must have the same dimensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #558

_image_value = Instance(ImageData)

_cmap = Trait(jet, Callable)
_cmap = Trait(viridis, Callable)

#---------------------------------------------------------------------------
# Public View interface
Expand Down Expand Up @@ -396,7 +396,7 @@ def update_view(self):
if self.model is not None and self.view is not None:
self.view.update(self.model)

options_dict = {'colormap' : "jet",
options_dict = {'colormap' : "viridis",
'num_levels' : 15,
'function' : "tanh(x**2+y)*cos(y)*jn(0,x+y*2)"}
model=Model(**options_dict)
Expand All @@ -418,7 +418,7 @@ def main(argv=None):
parser = OptionParser(usage=usage, version="%prog 1.0")

parser.add_option("-c", "--colormap",
action="store", type="string", dest="colormap", default="jet",
action="store", type="string", dest="colormap", default="viridis",
metavar="CMAP", help="choose a default colormapper")

parser.add_option("-n", "--nlevels",
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/cmap_image_aspect_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot
from chaco.api import ArrayPlotData, viridis, Plot
from chaco.tools.api import PanTool, ZoomTool

#===============================================================================
Expand All @@ -40,7 +40,7 @@ def _create_plot_component():
img_plot = plot.img_plot("imagedata",
xbounds=(0, 10),
ybounds=(0, 5),
colormap=jet)[0]
colormap=viridis)[0]
img_plot.index_mapper.aspect_ratio = 0.5
img_plot.index_mapper.maintain_aspect_ratio = True

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/cmap_image_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot
from chaco.api import ArrayPlotData, viridis, Plot
from chaco.tools.api import PanTool, ZoomTool

#===============================================================================
Expand All @@ -40,7 +40,7 @@ def _create_plot_component():
img_plot = plot.img_plot("imagedata",
xbounds=(0, 10),
ybounds=(0, 5),
colormap=jet)[0]
colormap=viridis)[0]

# Tweak some of the plot properties
plot.title = "My First Image Plot"
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/cmap_image_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, ColorBar, HPlotContainer, jet, \
from chaco.api import ArrayPlotData, ColorBar, HPlotContainer, viridis, \
LinearMapper, Plot
from chaco.tools.api import PanTool, RangeSelection, \
RangeSelectionOverlay, ZoomTool
Expand All @@ -46,7 +46,7 @@ def _create_plot_component():
name="my_plot",
xbounds=xbounds[:2],
ybounds=ybounds[:2],
colormap=jet)
colormap=viridis)

# Tweak some of the plot properties
plot.title = "Selectable Image Plot"
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/cmap_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Chaco imports
from chaco.api import ArrayPlotData, ColorBar, \
ColormappedSelectionOverlay, HPlotContainer, \
jet, LinearMapper, Plot
viridis, LinearMapper, Plot
from chaco.tools.api import PanTool, ZoomTool, RangeSelection, \
RangeSelectionOverlay

Expand All @@ -47,7 +47,7 @@ def _create_plot_component():
plot.plot(("index", "value", "color"),
type="cmap_scatter",
name="my_plot",
color_mapper=jet,
color_mapper=viridis,
marker = "square",
fill_alpha = 0.5,
marker_size = 6,
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/contour_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot
from chaco.api import ArrayPlotData, viridis, Plot
from chaco.tools.api import PanTool, ZoomTool

#===============================================================================
Expand Down Expand Up @@ -49,7 +49,7 @@ def _create_plot_component():
plot = Plot(pd, default_origin="bottom left")
plot.contour_plot("imagedata",
type="poly",
poly_cmap=jet,
poly_cmap=viridis,
xbounds=x,
ybounds=y)

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/basic/discrete_cmap_image_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot
from chaco.api import ArrayPlotData, viridis, Plot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not even using this color map in this example - looks like we're using the accent import from chaco.default_colormaps.

The example looks very weird with the accent color map - it looks much better with viridis.

from chaco.default_colormaps import accent
from chaco.tools.api import PanTool, ZoomTool

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/image_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot
from chaco.api import ArrayPlotData, viridis, Plot
from chaco.tools.api import PanTool, ZoomTool
from chaco.tools.image_inspector_tool import ImageInspectorTool, \
ImageInspectorOverlay
Expand All @@ -47,7 +47,7 @@ def _create_plot_component():# Create a scalar field to colormap
img_plot = plot.img_plot("imagedata",
xbounds = xbounds[:2],
ybounds = ybounds[:2],
colormap=jet)[0]
colormap=viridis)[0]

# Tweak some of the plot properties
plot.title = "My First Image Plot"
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/basic/image_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, jet, Plot, LassoOverlay
from chaco.api import ArrayPlotData, viridis, Plot, LassoOverlay
from chaco.tools.api import LassoSelection, LassoSelection

#===============================================================================
Expand Down Expand Up @@ -55,7 +55,7 @@ def _create_plot_component():# Create a scalar field to colormap
img_plot = plot.img_plot("imagedata",
xbounds=xbounds[:2],
ybounds=ybounds[:2],
colormap=jet)[0]
colormap=viridis)[0]

# Tweak some of the plot properties
plot.title = "Image Plot with Lasso"
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/canvas/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Chaco imports
from chaco.api import AbstractOverlay, ArrayPlotData, \
Plot, jet, ScatterPlot, LinePlot, LinearMapper
Plot, viridis, ScatterPlot, LinePlot, LinearMapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, looks like we're not using the viridis color map in this plot but im not sure what color map is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't think a color map is used anywhere, they're all just line plots with the color explicitly set to blue.

from chaco.tools.api import PanTool, ZoomTool , LegendTool

# Canvas imports
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/cursor_tool_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Enthought library imports
from chaco.api import create_line_plot, OverlayPlotContainer, \
HPlotContainer, Plot, ArrayPlotData, jet
HPlotContainer, Plot, ArrayPlotData, viridis
from chaco.tools.api import PanTool, ZoomTool
from chaco.tools.cursor_tool import CursorTool, BaseCursorTool
from enable.component_editor import ComponentEditor
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(self):
cmapImgPlot = img.img_plot("img",
xbounds = xy_range,
ybounds = xy_range,
colormap = jet)[0]
colormap = viridis)[0]

container.add(img)

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/nonlinear_color_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Chaco imports
from chaco.api import ArrayPlotData, Plot, ColorBar, HPlotContainer, \
LinearMapper, LogMapper, CMapImagePlot, \
TransformColorMapper, jet
TransformColorMapper, viridis
from chaco.tools.api import PanTool, ZoomTool


Expand Down Expand Up @@ -103,7 +103,7 @@ def _create_plot_component(model):
plot = Plot(pd, padding=50)

# Use a TransformColorMapper for the color map.
tcm = TransformColorMapper.from_color_map(jet)
tcm = TransformColorMapper.from_color_map(viridis)

# Create the image plot renderer in the main plot.
renderer = plot.img_plot("imagedata",
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/shell/add_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Enthought library imports
from chaco.shell import show, title, pcolor, colormap, curplot
from chaco.default_colormaps import jet
from chaco.default_colormaps import viridis

# Crate some scalar data
xs = linspace(0,10,200)
Expand All @@ -23,7 +23,7 @@
pcolor(x, y, z, name='sin_x_times_y')

# Change the color mapping
colormap(jet)
colormap(viridis)

# Add some titles
title("pseudo colormap image plot")
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/shell/contourf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Enthought Library Imports
from chaco.shell import contourf, colormap, title, show
from chaco.default_colormaps import jet
from chaco.default_colormaps import viridis


# Crate some scalar data
Expand All @@ -19,7 +19,7 @@

# Create a filled contour plot
contourf(x,y,z)
colormap(jet)
colormap(viridis)

# Add some titles
title("filled contour plot")
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/shell/pcolor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Enthought library imports
from chaco.shell import show, title, pcolor, colormap
from chaco.default_colormaps import jet
from chaco.default_colormaps import viridis


# Crate some scalar data
Expand All @@ -23,7 +23,7 @@
pcolor(x,y,z)

#change the color mapping
colormap(jet)
colormap(viridis)

# Add some titles
title("pseudo colormap image plot")
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/vtk/cmap_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Chaco imports
from chaco.api import ArrayPlotData, ColorBar, \
ColormappedSelectionOverlay, OverlayPlotContainer, \
jet, LinearMapper, Plot
viridis, LinearMapper, Plot
from chaco.tools.api import PanTool, ZoomTool, RangeSelection, \
RangeSelectionOverlay, MoveTool

Expand All @@ -48,7 +48,7 @@ def create_plot():
plot.plot(("index", "value", "color"),
type="cmap_scatter",
name="my_plot",
color_mapper=jet,
color_mapper=viridis,
marker = "square",
fill_alpha = 0.5,
marker_size = 6,
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/vtk/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from scipy import fft

# Enthought library imports
from chaco.default_colormaps import jet
from chaco.default_colormaps import viridis
from traits.api import HasTraits, Any

# Chaco imports
Expand Down Expand Up @@ -72,7 +72,7 @@ def create_plot_component(obj):
name='Spectrogram',
xbounds=xbounds,
ybounds=ybounds,
colormap=jet,
colormap=viridis,
)
range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
range_obj.high = 5
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/scipy2008/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from numpy import linspace, meshgrid, exp

from chaco.api import ArrayPlotData, Plot, jet
from chaco.api import ArrayPlotData, Plot, viridis
from enable.component_editor import ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import Item, View
Expand All @@ -27,7 +27,7 @@ def __init__(self):
# Create a Plot and associate it with the PlotData
plot = Plot(plotdata)
# Create an image plot in the Plot
plot.img_plot("imagedata", colormap=jet)
plot.img_plot("imagedata", colormap=viridis)
self.plot = plot

#===============================================================================
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/scipy2008/traits_image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from numpy import linspace, meshgrid, exp

from chaco.api import ArrayPlotData, Plot, jet
from chaco.api import ArrayPlotData, Plot, viridis
from enable.component_editor import ComponentEditor
from traits.api import Enum, HasTraits, Instance
from traitsui.api import Group, Item, View
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(self):
plot = Plot(plotdata)
# Create an image plot in the Plot
self.renderer = plot.img_plot("imagedata", name="plot1",
xbounds=xgrid, ybounds=ygrid, colormap=jet)[0]
xbounds=xgrid, ybounds=ygrid, colormap=viridis)[0]
self.plot = plot

def _origin_changed(self):
Expand Down
Loading