Python matplotlib.pyplot.colormaps() Examples
The following are 5
code examples of matplotlib.pyplot.colormaps().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: QtShortCuts.py From pylustrator with GNU General Public License v3.0 | 5 votes |
def __init__(self, value: str): """ initialize with a color """ super().__init__(value) import matplotlib.pyplot as plt self.maps = plt.colormaps() self.setAcceptDrops(True) self.setAlignment(QtCore.Qt.AlignHCenter) self.setColor(value, True)
Example #2
Source File: QtGui.py From pylustrator with GNU General Public License v3.0 | 5 votes |
def figureSwapColor(figure: Figure, new_color: str, color_base: str): """ swap two colors of a figure """ if getattr(figure, "color_artists", None) is None: figureListColors(figure) changed_cmaps = [] maps = plt.colormaps() for data in figure.color_artists[color_base]: # get the data color_type_name, artist, value, cmap, index = data # if the color is part of a colormap, update the colormap if cmap: # update colormap if cmap not in changed_cmaps: changed_cmaps.append(cmap) if getattr(cmap, "set_color", None) is not None: cmap.set_color(new_color, index) if getattr(cmap, "set_color", None) is None: if new_color in maps: cmap = plt.get_cmap(new_color) else: getattr(artist, "set_" + color_type_name)(new_color) artist.figure.change_tracker.addChange(artist, ".set_" + color_type_name + "(\"%s\")" % (new_color,)) continue # use the attributes setter method getattr(artist, "set_" + color_type_name)(cmap(value)) artist.figure.change_tracker.addChange(artist, ".set_" + color_type_name + "(plt.get_cmap(\"%s\")(%s))" % ( cmap.name, str(value))) else: if new_color in maps: cmap = plt.get_cmap(new_color) getattr(artist, "set_" + color_type_name)(cmap(0)) artist.figure.change_tracker.addChange(artist, ".set_" + color_type_name + "(plt.get_cmap(\"%s\")(%s))" % ( cmap.name, str(0))) else: # use the attributes setter method getattr(artist, "set_" + color_type_name)(new_color) artist.figure.change_tracker.addChange(artist, ".set_" + color_type_name + "(\"%s\")" % (new_color,))
Example #3
Source File: QtGui.py From pylustrator with GNU General Public License v3.0 | 5 votes |
def colors_changed(self): """ when the colors changed """ if self.trigger_no_update: return maps = plt.colormaps() # when the colors in the text edit changed for index, color in enumerate(self.colors_text_widget.toPlainText().split("\n")): try: color = mpl.colors.to_hex(color.strip()) except ValueError: if color not in maps: continue if len(self.color_buttons_list) <= index: self.addColorButton(color) self.color_buttons_list[index].setColor(color)
Example #4
Source File: tm_func.py From TFCE_mediation with GNU General Public License v3.0 | 5 votes |
def paint_surface(lowthresh, highthres, color_scheme, data_array, save_colorbar = True): colormaps = np.array(plt.colormaps(),dtype=np.str) if (str(color_scheme) == 'r_y') or (str(color_scheme) == 'red-yellow'): out_color_array = convert_redtoyellow(np.array((float(lowthresh),float(highthres))), data_array, save_colorbar = save_colorbar) elif (str(color_scheme) == 'b_lb') or (str(color_scheme) == 'blue-lightblue'): out_color_array = convert_bluetolightblue(np.array((float(lowthresh),float(highthres))), data_array, save_colorbar = save_colorbar) elif np.any(colormaps == str(color_scheme)): out_color_array = convert_mpl_colormaps(np.array((float(lowthresh),float(highthres))), data_array, str(color_scheme), save_colorbar = save_colorbar) else: print("Error: colour scheme %s does not exist" % str(color_scheme)) quit() return out_color_array # strips basename
Example #5
Source File: QtShortCuts.py From pylustrator with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent: QtWidgets.QWidget, map): """ initialize the dialog with all the colormap of matplotlib """ QtWidgets.QDialog.__init__(self, parent) main_layout = QtWidgets.QVBoxLayout(self) self.layout = QtWidgets.QHBoxLayout() main_layout.addLayout(self.layout) button_layout = QtWidgets.QHBoxLayout() main_layout.addLayout(button_layout) self.button_cancel = QtWidgets.QPushButton("Cancel") self.button_cancel.clicked.connect(lambda x: self.done(0)) button_layout.addStretch() button_layout.addWidget(self.button_cancel) self.maps = plt.colormaps() self.buttons = [] self.setWindowTitle("Select colormap") # Have colormaps separated into categories: # http://matplotlib.org/examples/color/colormaps_reference.html cmaps = [('Perceptually Uniform Sequential', [ 'viridis', 'plasma', 'inferno', 'magma']), ('Sequential', [ 'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']), ('Sequential (2)', [ 'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper']), ('Diverging', [ 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']), ('Qualitative', [ 'Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']), ('Miscellaneous', [ 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv', 'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])] for cmap_category, cmap_list in cmaps: layout = QtWidgets.QVBoxLayout(self) label = QtWidgets.QLabel(cmap_category) layout.addWidget(label) label.setFixedWidth(150) for cmap in cmap_list: button = QtWidgets.QPushButton(cmap) button.setStyleSheet("text-align: center; border: 2px solid black; "+self.getBackground(cmap)) button.clicked.connect(lambda x, cmap=cmap: self.buttonClicked(cmap)) self.buttons.append(button) layout.addWidget(button) layout.addStretch() self.layout.addLayout(layout)