Skip to main content

All Questions

0 votes
1 answer
20 views

No colours in legend when using zero handlelength with colours from a colourmap

I'm trying to plot multiple lines, using the colours from the viridis colourmap. I want to set the handlelength=0 in the legend, and when I do, the legend is now totally blank. If I don't mess around ...
Steven Thomas's user avatar
1 vote
2 answers
714 views

Display matplotlib legend element as 2D line of colormap

I wish to modify the 2D line in my legend to plot as line segments (or another method like patches) that will display the range of my colormap (here viridis_r) instead of a singular color. While the ...
Wilson Sauthoff's user avatar
1 vote
1 answer
102 views

How to generate several legends for single plot matplotlib

I was making a plot of f(x,y,z) and wanted this to be displayed in a 2D-plane. To avoid cluttering my legend i decided to have different linestyles for y, different colors for z and place the two in ...
Vegard Gjeldvik Jervell's user avatar
0 votes
1 answer
4k views

Plotting bar charts with a colormap legend

Consider the following: import matplotlib.pyplot as plt from matplotlib import cm import numpy as np y = np.array([1, 4, 3, 2, 7, 11]) colors = cm.hsv(y / float(max(y))) plot = plt.scatter(y, y, c = ...
Andy's user avatar
  • 21
1 vote
0 answers
112 views

Matplotlib Legend and colormaps from panda dataframes

I am trying to plot some graphs with Python. Specifically I am working with dataframes. I would like to know how to do the next couple of things: Adapt the legend of the plots using the correspondant ...
felixpradoh's user avatar
2 votes
1 answer
3k views

LEGEND in a 3D bar plot as a colormap

I have a 3D bar plot in matplotlib which consists of a total 40 bars and at the moment it is quite confusing.I converted my data array to an array of colors using a colormap. colors = plt.cm.jet(data....
Dreamer's user avatar
  • 25
7 votes
1 answer
4k views

How to put multiple colormap patches in a matplotlib legend?

Situation at hand: I have multiple groups of lines, where the lines within the same group vary according to some group specific parameter. I assign each of these lines within the same group a color ...
Zaus's user avatar
  • 1,301
1 vote
1 answer
3k views

How to iteratively plot lines with colors from a sequential color function [duplicate]

I would like to plot 3 figures in python. I plotted it manually. The code is: import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots(1, 1) Semesters=np.arange(1,7,1) y1=np....
user10316146's user avatar
2 votes
1 answer
1k views

Why doesn't the color of the points in a scatter plot match the color of the points in the corresponding legend?

I have a sample scatterplot via matplotlib via the code below. import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 100, 501) y = np.sin(x) label = 'xy data sample' plt.scatter(x, ...
user avatar
5 votes
2 answers
1k views

Issue with Matplotlib scatterplot and Color maps

I am working on a project that involves applying colormaps to scatterplots generated in matplotlib. My code works as expected, unless the scatterplot being generated has exactly four points. This is ...
Beane's user avatar
  • 556
6 votes
2 answers
2k views

Matplotlib: How to plot a small rectangle filled with a colormap as a legend

Instead of a plotting a colorbar next to my plot, I want to plot a small rectangle filled with the colormap as a legend. I already can plot a small rectangle filled with any color, by doing the ...
firefly2517's user avatar
1 vote
1 answer
4k views

Matplotlib scatter plot different colors in legend and plot

I have a scatter plot of multiple y-values for the same x-value, in matplotlib (python 2.7). There are different colors for all the plotted y-values. See the plot below. Now, here is the code: ...
edesz's user avatar
  • 12.2k