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

MAINT: Minor improvement for scalarbar #486

Merged
merged 4 commits into from Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions pyvista/plotting/plotting.py
Expand Up @@ -11,6 +11,7 @@
import scooby
import vtk
from vtk.util import numpy_support as VN
from vtk.util.numpy_support import numpy_to_vtk, vtk_to_numpy
import warnings

import pyvista
Expand Down Expand Up @@ -2478,16 +2479,8 @@ def add_scalar_bar(self, title=None, n_labels=5, italic=False,
# Create scalar bar
self.scalar_bar = vtk.vtkScalarBarActor()
if background_color is not None:
from ..core.common import vtk_to_numpy, numpy_to_vtk
if not isinstance(background_color, collections.Iterable):
raise TypeError('Expected type for `background_color`'
'is list, tuple or np.ndarray: '
'{} is given'.format(type(background_color)))
if len(background_color) != 3:
raise ValueError('Expected length for `background_color` is 3: '
'{} is given'.format(len(background_color)))
background_color = np.asarray(background_color)
background_color = np.append(background_color, 1.0) * 255.
background_color = parse_color(background_color, opacity=1.0)
background_color = np.array(background_color) * 255

lut = vtk.vtkLookupTable()
lut.DeepCopy(mapper.lookup_table)
Expand Down
1 change: 1 addition & 0 deletions tests/test_plotting.py
Expand Up @@ -175,6 +175,7 @@ def test_plot_add_scalar_bar():
plotter.add_mesh(sphere)
plotter.add_scalar_bar(label_font_size=10, title_font_size=20, title='woa',
interactive=True, vertical=True)
plotter.add_scalar_bar(background_color='white', n_colors=256)


@pytest.mark.skipif(NO_PLOTTING, reason="Requires system to support plotting")
Expand Down