Skip to main content

All Questions

Tagged with
0 votes
0 answers
29 views

How to plot the legend with combined_plot (ggplot2)

I created this script to display some environmental impacts for my research. `legend_plot <- ggplot(data_longGW, aes(x = Crop_cycleGW, y = kg_CO2_eq, fill = Category)) + geom_bar(stat = "...
Guido Evangelista's user avatar
1 vote
0 answers
30 views

Why is the coding for legend on my barplot not working after update?

I updated Rstudio and suddenly none of my legends are working on my barplots. It's my first time asking for help on here, so hopefully I am providing the info needed to get answers? Coding is below. ...
Rebecca Connor's user avatar
0 votes
1 answer
40 views

How to reverse legend order without affecting bar order in Plotly R? [duplicate]

I am creating a stacked bar chart using Plotly in R, and the order of the items in the legend is the reverse of the order that I want. library(dplyr) library(plotly) library(forcats) set.seed(1) df &...
Ernest Au's user avatar
1 vote
2 answers
42 views

Separate Legend Entries for Individual Outlined Overlapping Bars

I am creating a ggplot with multiple overlapping bar plots. The first underlying bar is filled with color and then I overlay one more set of bars with just an outline to show sub-components. I would ...
fowlermw's user avatar
0 votes
1 answer
78 views

How to show values next to bars in tornado chart using ggplot in R [closed]

I have this table (T_Tornado_Total_EM_HM_sort): And these are the lines that I used to make the tornado chart: ggplot(T_Tornado_Total_EM_HM_sort, aes(Tipovi_troškova, RSD, fill=Populacija)) + ...
newtoR's user avatar
  • 35
0 votes
1 answer
34 views

Legend of the library Fantaxtic

I am running the library fantaxtic in R studio. I want to make a bar chart or something like that. However, in the legend I don't want any title in the legend and the category Other is located at the ...
user1892205's user avatar
1 vote
1 answer
31 views

Order ggplot legend differently than elements in plot

Is there a way to order a legend in ggplot differently than the elements on the plot. for example I want the legend to be ordered Calanoida, Cladocera, Rotifera, and Cyclopoida but I want the ggplot ...
confusedindividual's user avatar
0 votes
0 answers
34 views

Same scale in legend for circular bar plot

Building on this post and code (with reproducible example) Different fill color for negative values in circular barplot, I want to plot two of these figures together as a comparison, like this: But ...
MoonS's user avatar
  • 175
3 votes
1 answer
71 views

Sharing multiple ggplot legend symbols with one label

I am trying to create a stacked barplot for one response over time (Year) across 3 different sites that I've separated into different facets (facet_wrap). I would like different colours per facet, and ...
James White's user avatar
1 vote
0 answers
131 views

How to add space between Legend text and chart in ChartJs v4

I'm using Chart.js version 4.4.1, and I want to increase the space between the legend and the chart. I need a solution for barchart. I'm sharing the code for the bar chart. I've checked several posts, ...
Aishwarya's user avatar
0 votes
1 answer
72 views

How to create a bar graph to visually represent two variables, while keeping the same color for the x-axis variable?

For example, here is a data. Genotype=c("A","A","B","B","C","C","A","A","B","B","C","...
Jin.w.Kim's user avatar
  • 884
1 vote
1 answer
31 views

How do I get column names under a barplot from aggregated data using multiple variables?

I have a data file with tree data called ufc.csv, and after reading it in with a read.csv() function, I used an aggregate function to get the means of tree diameter (Dbh) and tree height (Height) ...
robotnoises's user avatar
1 vote
1 answer
56 views

Creating Separate Legend for Specific Line in ggplot2

I'm working on a data visualization project in R using the ggplot2 package. I have a bar plot with two bars per year and a trend line that applies to one of the bars. I'm trying to create a clear ...
estrix's user avatar
  • 15
2 votes
2 answers
71 views

How to consolidate labels in legend

So, the script below requests data from postgres database and draws a diagram. The requested data is a table with 4 columns (ID, Object, Percentage, Color). The data: result = [ (1, 'Apple', 10, '...
muted_buddy's user avatar
1 vote
1 answer
250 views

How to make the legend appear in a stacked bar chart with `plotly` in R

I want to make a stacked bar chart with a slider in plotly. I took inspiration from the plotly website. I can't manage to insert the legend, maybe because I didn't use the legendgroup argument ...
Julien's user avatar
  • 1,664
0 votes
1 answer
59 views

ggplot2: Legend with barplot and line

I am trying to produce a graph that shows averages by decile of two variables (as they have very different values, I added a second y-axis). On variable is represented with bars, the other one with a ...
Antoine D's user avatar
3 votes
1 answer
198 views

A legend marker for each unique texture in the same bar trace, with Plotly Graph Objects in Python

I have the following code as example: x=[1,2,3,4] y=[2,2,4,3] colors = ["blue","blue","orange","blue"] textures = ["","","x","...
33fred33's user avatar
0 votes
1 answer
432 views

Why does my legend not match the colour of my bars in ggplot2?

I converted the bars of my graph from gray with a coloured outline to a solid fill which resulted in half of my error bars not being visible due to being the same colour. I therefore changed the ...
e_putyora's user avatar
1 vote
4 answers
141 views

How to remove a single item from legend in ggplot

This question is related to this How to properly create this barplot in R using ggplot2? If have this code which produces this plot: library(tidyverse) df=tibble(type=c('grass','forest','desert','crop'...
TarJae's user avatar
  • 78.1k
1 vote
1 answer
180 views

Force ggplot2 to show legends (barchar and geom_line)

Easy question: I'm creating a barchart in ggplot2 with both a stacked barchart and a geom_line referring to different parts of the same dataset. No matter what I do, I'm unable to show the legends (...
Devon's user avatar
  • 27
0 votes
1 answer
243 views

Change order of legend in ggplot2

Example graph of my problem: https://i.sstatic.net/PQirh.jpg (Code at bottom) I would like to reorder my legend in a bar plot in ggplot2. Currently the fill is on a scale from "Inside", &...
OptimisticKnut's user avatar
0 votes
1 answer
701 views

How to change the width of plot legend box in R

I want to make my legend box width look like the one on the left, but instead, I got the one on the right. I couldn't figure it out. I'm new in R, what function do I need to use?
campagne probs's user avatar
-1 votes
1 answer
150 views

Barplot subplot legend python

Hello everyone how can i make legend for 3 different bar color that code with subplot? Data frame: This is my code: fig,axs = plt.subplots(2,3, figsize=(30,20)) axs[0,1].bar(x = df_7_churn_tenure['...
Jovian Aditya's user avatar
0 votes
1 answer
527 views

Why the labels under chart are not corresponding with labels in legend in Chart.js for bar chart?

I would like to make a chart with labels on xAxes and the same labels in the legend. I was trying different solutions, but the best I got is the snippet below. I don't understand, why all bars are ...
Kida's user avatar
  • 800
1 vote
1 answer
773 views

How to align a single legend over two seaborn barplots?

I would like to have a single legend that nicely fits on top of both the subplots (doesn't necessarily need to span the entire width of the plots, but needs to be outside the plot). I know you can ...
JonnDough's user avatar
  • 887
3 votes
1 answer
2k views

Placing a Legend Title Above a Horizontal Legend Already Positioned at the Top of a Barplot ggplot

Issue: I have done a lot of research and tried many different solutions and I could not find an answer to my problem, at least not one that worked for me. I am attempting to place the legend title '...
Alice Hobbs's user avatar
  • 1,043
0 votes
1 answer
1k views

How to plot a barplot with different hatch and edge color with legends using matplotlib?

I would like to plot a barplot where bars have a different hatch and edge color using Matplotlib with its proper legends. I tried to plot but I couldn't generate proper legends with this code: import ...
Kamran Ansari's user avatar
1 vote
1 answer
379 views

adding a legend to a barplot at he top left

barcols <- c("green","red","purple") barcols barplot(table(gender$Alert.Level, gender$Gender),las=1, beside= TRUE, ylab= "Frequency", xlab="gender"...
John Williams's user avatar
0 votes
0 answers
78 views

Troubles with pyplot.bar legend

I'm having troubles introducing a legend in this chart. Can someone help me? I can plot the chart but everytime I try to apply a legend it doesn't work.. flags=['0','1','2','3','4','5'] ...
GLTCL's user avatar
  • 13
0 votes
1 answer
99 views

How to add legends to the barplot in R like shown in the below image?

I want to implement legend like tjhis
user18053372's user avatar

15 30 50 per page