legend-properties

How to add a string as the artist in matplotlib legend?

核能气质少年 提交于 2019-11-26 17:49:42
问题 I am trying to create a legend in a python figure where the artist is a string (a single letter) which is then labelled. For example I would like a legend for the following figure: import numpy as np import matplotlib.pyplot as plt import string N = 7 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * (15 * np.random.rand(N))**2 plt.scatter(x, y, s=area, c=colors, alpha=0.5) for i,j in enumerate(zip(x,y)): plt.annotate(list(string.ascii_uppercase)[i],xy=j)

Different legend-keys inside same legend in ggplot2

拜拜、爱过 提交于 2019-11-26 16:54:42
问题 Let's say I don't need a 'proper' variable mapping but still would like to have legend keys to help the chart understanding. My actual data are similar to the following df df <- data.frame(id = 1:10, line = rnorm(10), points = rnorm(10)) library(ggplot2) ggplot(df) + geom_line(aes(id, line, colour = "line")) + geom_point(aes(id, points, colour = "points")) Basically, I would like the legend key relative to points to be.. just a point, without the line in the middle. I got close to that with