legend

How to autoscaled graphs with picking legend (matplotlib)?

試著忘記壹切 提交于 2021-02-20 04:09:41
问题 I am working on a picking legend with matplotlib. The goal is to hide and shows curves, by clicking on the legend. I found this solution (Hiding lines after showing a pyplot figure), which works very well. I want improve this code to adapt automatically the axis after each clic on the legend. I don't know if it is possible. Do you have any hint? Their is an example of what I want on the images below. First of all, the Image 1 represents the graph. Then after clicking on the legend 5*sin(x),

How to autoscaled graphs with picking legend (matplotlib)?

☆樱花仙子☆ 提交于 2021-02-20 04:06:20
问题 I am working on a picking legend with matplotlib. The goal is to hide and shows curves, by clicking on the legend. I found this solution (Hiding lines after showing a pyplot figure), which works very well. I want improve this code to adapt automatically the axis after each clic on the legend. I don't know if it is possible. Do you have any hint? Their is an example of what I want on the images below. First of all, the Image 1 represents the graph. Then after clicking on the legend 5*sin(x),

Looping through R Plotly with subplot and hiding all legend except one

和自甴很熟 提交于 2021-02-19 07:48:05
问题 I need to loop through i iteration of factors, and each factor needs to be plotted as one plot in a subplot. What I would like to do is hiding the legend for every iteration bar the first one, and use legendgroup to tie all the legends together. This is what I have done so far: library(plotly) library(dplyr) mtcars %>% mutate(vs = as.factor(vs)) %>% group_split(cyl) %>% lapply(function(i) { #show.legend <- ifelse(i == 1, TRUE, FALSE) show.legend <- if(i == 1) {TRUE} else {FALSE} plot_ly( data

Get ggplot2 legend to display percentage sign in r

孤者浪人 提交于 2021-02-18 09:10:28
问题 Below is a reproducible example of the issue I am trying to solve. I have created a heatmap of sorts in ggplot2 and things have been going well. Since I have put percentage signs on the data to use with geom_text I would like to make the legend of geom_tile also to display percent signs (I can only multiply the actual values by 100 right now). Ideally I would like the legend bar on the right to show 8%, 4%, 0%, -4%, -8%. #load in libraries require(plyr) require(dplyr) require(reshape2)

Get ggplot2 legend to display percentage sign in r

青春壹個敷衍的年華 提交于 2021-02-18 09:09:13
问题 Below is a reproducible example of the issue I am trying to solve. I have created a heatmap of sorts in ggplot2 and things have been going well. Since I have put percentage signs on the data to use with geom_text I would like to make the legend of geom_tile also to display percent signs (I can only multiply the actual values by 100 right now). Ideally I would like the legend bar on the right to show 8%, 4%, 0%, -4%, -8%. #load in libraries require(plyr) require(dplyr) require(reshape2)

Reverse the order of legend

喜你入骨 提交于 2021-02-17 18:44:39
问题 I use the following code to plot the bar graph. Need to present a legend in reverse order. How can I do it? colorsArr = plt.cm.BuPu(np.linspace(0, 0.5, len(C2))) p = numpy.empty(len(C2), dtype=object) plt.figure(figsize=(11,11)) prevBar = 0 for index in range(len(C2)): plt.bar(ind, C2[index], width, bottom=prevBar, color=colorsArr[index], label=C0[index]) prevBar = prevBar + C2[index] # positions of the x-axis ticks (center of the bars as bar labels) tick_pos = [i+(width/2) for i in ind] plt

Reverse the order of legend

陌路散爱 提交于 2021-02-17 18:43:10
问题 I use the following code to plot the bar graph. Need to present a legend in reverse order. How can I do it? colorsArr = plt.cm.BuPu(np.linspace(0, 0.5, len(C2))) p = numpy.empty(len(C2), dtype=object) plt.figure(figsize=(11,11)) prevBar = 0 for index in range(len(C2)): plt.bar(ind, C2[index], width, bottom=prevBar, color=colorsArr[index], label=C0[index]) prevBar = prevBar + C2[index] # positions of the x-axis ticks (center of the bars as bar labels) tick_pos = [i+(width/2) for i in ind] plt

Reverse the order of legend

纵饮孤独 提交于 2021-02-17 18:43:08
问题 I use the following code to plot the bar graph. Need to present a legend in reverse order. How can I do it? colorsArr = plt.cm.BuPu(np.linspace(0, 0.5, len(C2))) p = numpy.empty(len(C2), dtype=object) plt.figure(figsize=(11,11)) prevBar = 0 for index in range(len(C2)): plt.bar(ind, C2[index], width, bottom=prevBar, color=colorsArr[index], label=C0[index]) prevBar = prevBar + C2[index] # positions of the x-axis ticks (center of the bars as bar labels) tick_pos = [i+(width/2) for i in ind] plt

ggplot2 add manual legend for two data series

耗尽温柔 提交于 2021-02-17 05:39:10
问题 I have this dataframe: Control Stress days sd_control sd_stress X1 0.9702100 0.9343627 X1 0.001900535 0.07035645 X2 0.9666619 0.8595523 X2 0.014946893 0.04066567 X3 0.9165654 0.7160598 X3 0.072655343 0.07025344 X4 0.9208237 0.6668044 X4 0.050870831 0.08736982 X5 0.8766547 0.7660685 X5 0.073588197 0.04868614 X6 0.9599553 0.7937444 X6 0.041559836 0.05326769 X7 0.9736297 0.8188934 X7 0.003817743 0.06272428 and based on this data I've done this plot: With the following code: significance <- data

ggplot2 add manual legend for two data series

痞子三分冷 提交于 2021-02-17 05:39:05
问题 I have this dataframe: Control Stress days sd_control sd_stress X1 0.9702100 0.9343627 X1 0.001900535 0.07035645 X2 0.9666619 0.8595523 X2 0.014946893 0.04066567 X3 0.9165654 0.7160598 X3 0.072655343 0.07025344 X4 0.9208237 0.6668044 X4 0.050870831 0.08736982 X5 0.8766547 0.7660685 X5 0.073588197 0.04868614 X6 0.9599553 0.7937444 X6 0.041559836 0.05326769 X7 0.9736297 0.8188934 X7 0.003817743 0.06272428 and based on this data I've done this plot: With the following code: significance <- data