legend

How can I change the legend linetype in ggplot2?

大城市里の小女人 提交于 2020-06-23 12:32:07
问题 I have this simple plot where I cannot change the linetype in the legend according to the linetype in the plot using scale_linetype_manual. The code to produce the plot is : library(ggplot2) x_1 <- rep(0:6, each = 2) pdf_1 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) x_2 <- rep(3:9, each = 2) pdf_2 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) data_1 <- data.frame(x_1, pdf_1,x_2,pdf_2) ggplot()+ geom_line(data=data_1,aes(x=x_1, y=pdf_1, color=

R (ggplot) function to add an 'empty' row in an existing legend, split legend?

て烟熏妆下的殇ゞ 提交于 2020-06-16 18:40:14
问题 I'm currently working on a plot. It's all coming together, but i'm wondering about one thing... I tried googling this, but I couldn't found what I was looking for. Right now, I've created a legend that I liked. With 'scale_color_manual' and 'scale_size_manual', I've created a combined legend that includes the thickness of the corresponding line and the color. I have put the code I used below. scale_color_manual(name = "combined legend", labels = c("Nederland totaal", "Noord-Holland", "Utrecht

Add legend to geopandas

自作多情 提交于 2020-06-16 18:02:28
问题 I have a map of Chile (http://labgeo.ufro.cl/fichas/chile_geo/ficha_cl_geo.html first link that says "Chile continental) and would like to plot it and add some points of centers for which I have latitude and longitud data. I am newbie with geopandas and matplotlib but I managed to plot the map with the centers as dots of different colors using the suggested answer for matplotlib from this post: Color by Column Values in Matplotlib Here is my code: #Loading data, since I am making the

R ggplot2 legend inside the figure

孤街浪徒 提交于 2020-06-09 08:39:04
问题 So, I have the following data.frame, and I want to generate two plots in one graph for yval vs. xval, for each zval and type tp. The lef > df xval yval se zval cond 1 1.0 1.831564e-02 1.831564e-03 0 a 2 1.2 2.705185e-02 2.705185e-03 0 a 3 1.4 3.916390e-02 3.916390e-03 0 a 4 1.6 5.557621e-02 5.557621e-03 0 a 5 1.8 7.730474e-02 7.730474e-03 0 a 6 2.0 1.053992e-01 1.053992e-02 0 a 7 2.2 1.408584e-01 1.408584e-02 0 a 8 2.4 1.845195e-01 1.845195e-02 0 a 9 2.6 2.369278e-01 2.369278e-02 0 a 10 2.8 2

matplotlib add legend with multiple entries for a single scatter plot

旧城冷巷雨未停 提交于 2020-05-27 13:11:45
问题 I am making a scatter plot for a dataset that looks like this: x = [1, 1, 2, 2, 3, 3, 4, 4] y = [1, 2, 3, 4, 1, 2, 3, 4] labels = [1, 3, 0, 2, 2, 1, 0, 3] colors = np.array(plt.rcParams['axes.prop_cycle'].by_key()['color']) plt.scatter(x, y, color=colors[labels]) If I call plt.legend , only one entry will be shown, for the entire dataset, with the first symbol. How do I create a legend with all four elements in it, displayed as if I had plotted four separate datasets? Probably relevant:

matplotlib add legend with multiple entries for a single scatter plot

北城余情 提交于 2020-05-27 13:10:53
问题 I am making a scatter plot for a dataset that looks like this: x = [1, 1, 2, 2, 3, 3, 4, 4] y = [1, 2, 3, 4, 1, 2, 3, 4] labels = [1, 3, 0, 2, 2, 1, 0, 3] colors = np.array(plt.rcParams['axes.prop_cycle'].by_key()['color']) plt.scatter(x, y, color=colors[labels]) If I call plt.legend , only one entry will be shown, for the entire dataset, with the first symbol. How do I create a legend with all four elements in it, displayed as if I had plotted four separate datasets? Probably relevant:

Controlling legend and colors for raster values in R?

只愿长相守 提交于 2020-05-26 09:39:04
问题 I'm trying to plot an ESRI Grid as a raster image of a surface. I've figured out how to make the plot, but not how to control R's color scale. # open necessary libraries library("raster") library("rgdal") library("ncdf") # goal: select an ESRI Grid ASCII file and plot it as an image. infile <- file.choose("Results") r <- raster(infile) # read in metadata from ESRI output file, split up into relevant variables info <- read.table(infile, nrows=6) NCOLS <- info[1,2] NROWS <- info[2,2] XLLCORNER

Insert icon in the legend of a map generated by leaflet

不羁的心 提交于 2020-05-16 03:10:10
问题 I created a map with the leaflet with two databases (df and df1). I managed to insert the legend of the database df, which are points referring to the clusters that I generated. However I would like to insert the database icon df1 in this same Legend. I inserted an attached image to illustrate. In the same legend, it shows the clusters, as well as the icon for the df1 database. The description of this icon I designated as "contact point". The executable code is below library(leaflet) library

Figure labels: add text on graphs in the same location despite figure size

给你一囗甜甜゛ 提交于 2020-05-15 04:48:29
问题 I want to know how it's possible to add a letter to reference a graph in R, but without always changing the y and x value. I want the text to be always at the same place (on the same baseline, and at the same relative distance on the x axis. set.seed(1234) plot(2,3) text(x = 1.5,y = 4, "A", font = 2 ) plot(rnorm(100)) text(x = 1.5,y = 2, "B", font = 2) As you can see, the letter B is not at the same distance on the x axis and it's a little down. I would like this to be adjusting automatically

Is it possible in chartjs to hide certain dataset legends?

﹥>﹥吖頭↗ 提交于 2020-05-10 07:04:37
问题 Is it possible to only hide certain dataset legends in chartjs? I know it is possible to hide all with options: { legend: { display: false 回答1: Short answer: Yes it is possible. Unfortunately it's not quite as simple as the developers could make it. If you know what the text value of the item being displayed in the legend is, then you can filter that out. After reading through the Chart.js docs I found the section Legend Label Configuration that details a filter function that can be used to