Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [ggplot2]

ggplot2 is an actively maintained open-source chart-drawing package for R, written by Hadley Wickham, based upon the principles of "Grammar of Graphics". It partially replaces R's basic plot and the lattice package, while providing a clean, powerful, orthogonal and fun API.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

What is the best visualization to demonstrate Likert proportion differences between treatment groups?

I ran a survey experiment a month or so ago and have been struggling to find the best way to visualize the proportions of Likert responses between the control and treatment groups. Brief context for ...
xandyravage's user avatar
0 votes
0 answers
13 views

How to visualize correlation values coming from two data frame for comparison

I am working on a project wherein we are comparing two methods used for modeling gene expression. One method is using elastic net and other is using lasso regression. In one method: we see that ...
Rhea Bedi's user avatar
0 votes
0 answers
81 views

Strange bug in ggplot2 with facet_grid and large datasets

Here is a basic example that should definitively work ...
Perochkin's user avatar
  • 311
0 votes
1 answer
51 views

What is the reason behind this formula: 2 times interquartile range divided by length to the power of one third

In ggplot2 package documentation for geom_freqpoly, there is a formula in the last example which use a function to dynamically ...
rez's user avatar
  • 63
0 votes
1 answer
4k views

How to change line type in legend in ggplot in R

I have an issue with the "ggplot2"-package, where I cannot get the linetypes in the legend. The legnd only shows the color of each line, but not the specific type. My code looks like: <...
AndersMax's user avatar
1 vote
1 answer
471 views

making a contingency table with TRUE and FALSE values

I made the following contingency table already, however there should only be TRUE or FALSE and not all of them showing up on the table. How can I change that? my code is the following: ...
Bert's user avatar
  • 25
1 vote
0 answers
67 views

How to plot a PCA table [closed]

I'm studying PCA method with the package PCAmixdata because I have a dataset with numerical and categorical variable. This is my example code in R: ...
Inuraghe's user avatar
  • 481
0 votes
1 answer
3k views

How to change legend labels in line plot with ggplot2?

Context: I am trying to change the legend labels for the Indices variable which contains "Positive" and "Negative" in "d_posneg" data frame. Problem: However, my ...
n.baes's user avatar
  • 39
2 votes
0 answers
327 views

Graph legend for plot in Base R for class differentiated data gives incorrect representation of actual category

I am new to R. While working on my university assignments, I found that legends for Base R plot do not show correct information, hence I switched to ggplot2 wherever legends were needed. I observed ...
Vanjuli's user avatar
  • 21
1 vote
1 answer
49 views

Fit non-linear customised model

I have a data.frame that have two cols, $x=mz$ and $y=res$. There are about ~2 million rows in the DF. When I plot the graph I get the below. What I'd like to do is ...
V. Lad's user avatar
  • 11
1 vote
1 answer
186 views

ggplot2 for Cluster analysis (non-readible row names)

I have made a cluster analysis and ended up with dendrogram; however the row names are not readible (made a red rectangle). May I ask if there is way to adjust it? ...
Lola Kpiani's user avatar
1 vote
1 answer
131 views

Using glue to include information regarding selected observation

I would like my ggplot to display the state I had selected for better clarity but it seems like glue is only seeking for the first observation rather than my desired output. ...
zher4883's user avatar
0 votes
1 answer
1k views

Plot two categorical variables against two numeric variable in ggplot

In my dataset, I have two numeric revenue features, one for each month, and two categorical features one for region and other for value segment. what I want to do is compare these two revenues col by ...
Ehsno's user avatar
  • 3
0 votes
1 answer
1k views

How to plot a table with multiple columns as a box plot

I am trying to plot a box plot with the Trinucleotide as the x axis (so 64 trinucleotides on the x axis) and the frequency of each trinucleotide in each of 6 samples then color code the plot according ...
user14687500's user avatar
1 vote
1 answer
469 views

Using ggplot2 to create a bar chart [closed]

So I'm trying to create a simple bar chart of Survive vs Not Survive for the common Titanic data set in R. I keep getting just the number of No's and Yes's, and not the frequencies or counts ...
redfish993's user avatar
1 vote
1 answer
2k views

How can I plot a line for time series data with categorical intervals in R

I am working with single time-series measurements that I want to plot for the time window of about 1 week. This is the data I am working with. This is my R script: ...
Livingsten's user avatar
2 votes
0 answers
749 views

How to add RMSE value on a plot with ggplot [closed]

I added r2 value and the formula of the regression function but I also want RMSE value on my plot, maybe I need to add something but I could not see a proper answer to this question neither here nor ...
RS_girl's user avatar
  • 21
2 votes
1 answer
265 views

How to generate higher quality jpg plots on R [closed]

I have tried generating higher quality of data visualization plots from RStats. I tried increasing frame dimensions but it's still max at about ~350kb. How do I generate higher quality images from ...
BioIsaac's user avatar
1 vote
1 answer
39 views

How to get a (descriptive) overview of a large database?

I'm facing a data framework with ~ 20 k observations and 151 variables across 2078 subjects At first I am primarily interested in how the data looks like related to a single parameter. But I cannot ...
Ben's user avatar
  • 550
3 votes
1 answer
421 views

Adding a trend line or horizontal mean±stdev lines in facet_grid view

Today was the final day for an On Demand event I adminned. We got some data back from the provider today. Vendors bought in at different tiers, and only one T1 was allowed because they're a sponsor. ...
user208145's user avatar
1 vote
1 answer
144 views

Data visualization on three factors

I have three factors, Income(from source A),continuous variable Income(from source B), continuous variable Happiness index,continuous variable Suppose I have 500 samples. My goal is to show the ...
Jie's user avatar
  • 187
2 votes
1 answer
258 views

How to visualize categorical data with numeric columns

I have data like as shown below I would like to represent the above tabular data in a visual form. However, the below graph may not work because my real data as 50K unique drug names. So, is there ...
The Great's user avatar
  • 2,565
0 votes
1 answer
77 views

How to create a barplot using multiple column [closed]

My data is about boardgames which contain 1 to many catgeories each like this : ...
thoms's user avatar
  • 1
2 votes
3 answers
56 views

An appropiate data visualization?

I want to include a plot in my thesis to highlight regional differences in bicycle collision outcomes. Now there are several plot visualizations I could use, and I am not sure which one could be the ...
Lutz's user avatar
  • 121
2 votes
1 answer
4k views

Mirror column plot with different y-axis in ggplot

I am trying to convert this plot Into a mirror column plot I have two datasets: school_purchases recent_school_shootings I am not very experienced with visualisation but this is my approach ...
Ayush Ranjan's user avatar
0 votes
0 answers
5k views

Overlay Bar Plot

I am trying to turn the first overlay bar plot into the second which allows for comparison of 2 variables instead of just one. Included my current code below which creates the first chart comparing ...
DataGuy23's user avatar
5 votes
1 answer
50k views

How to plot multiple columns with ggplot in R?

I do have a data frame with different categorical and numerical columns with the following schema: Id | num_col_1 | num_col_2 | num_col_3 | cat_col_1 | cat_col_2 ...
Fredrik's user avatar
  • 1,007
1 vote
2 answers
287 views

R: Producing multiple plots (ggplot, geom_point) from a single CSV with multiple subcategories

I have a collection of bacteria data from approximately 140 monitoring locations in California. I would like to produce a scatterplot for each monitoring location with the Sampling Date on the Y-axis ...
Kota_K's user avatar
  • 35
0 votes
1 answer
539 views

Y-axis output is not order

I am currently attempting to output some data based on user agent strings. The strings are too messy to place into a plot similar to the one shown below, so I plotted their index instead. Why is my ...
Slyme's user avatar
  • 3
1 vote
1 answer
188 views

Display a subset of classes in axes in ggplot

I have the following plot, is there any way in ggplot to display just the numbers 1 to 10 instead of all of them? Numbers from 10 and after are not so important, but I need to display the ones before. ...
3nomis's user avatar
  • 541
3 votes
1 answer
248 views

ggplot (in R)/matplotlib (in Python) with linear model?

How can I plot the histogram below, using ggplot (R) and/or matplotlib (...
Learner132's user avatar
1 vote
1 answer
485 views

How to make a Power Spectral Density Plot in R

I have a time series point process representing neuron spikes. I have computed and plotted autocovariance using acf but now I need to plot the Power Spectral ...
Matthew Ciaramitaro's user avatar
0 votes
2 answers
4k views

How to plot using facet_wrap, over multiple pages as a .pdf files in r cran

I am using ggplot, to compare 114 unique studies for a particular variable I'm interested in. This is what I have used. ...
Shivy b's user avatar
  • 11
3 votes
2 answers
4k views

When Should I Use ggplot2 Instead of Tableau? [closed]

I am a student getting started with Tableau for the first time. My proficiency with ggplot2 is intermediate. I can create custom versions of the most popular kinds of charts in ggplot2 but nothing too ...
SKOR2's user avatar
  • 33
-1 votes
2 answers
99 views

Two quantities visualization

I have a problem figuring out how to visualize two simple quantities using R. I want to compare their size by visualizing two proportional spatial figures next to each other and the size proportional ...
Dominykas Tunaitis's user avatar
1 vote
0 answers
28 views

Visualising 2-step sequence data to spot the differences among two different user groups

I have the following data frame for a certain user group. Basically, it shows the current page, and the previous page visited across all users. For example, 81 users come from BLQ2_2 to visit BLQ2_1. ...
renakre's user avatar
  • 111
4 votes
1 answer
2k views

R recommendations while applying ggplot2 and plotly together to plot a graph

I have data frame having 3 columns namely index, Actual & Predicted (all column are numeric). I am using 2 packages plotly & ...
Manik's user avatar
  • 429
1 vote
0 answers
48 views

Infoviz for multinomials: miniature plots within plots in R's ggplot

I'm plotting fluctuations in a trinomial distribution across two dimensions. ...
enfascination's user avatar
3 votes
1 answer
1k views

How to plot two distribution curves in a faceted way in R/ggplot2?

I have two probability distribution curves, a Gamma and a standarized Normal, that I need to compare: ...
JulioSergio's user avatar
0 votes
1 answer
191 views

Interactive Data Visualisations

So I have finally gotten a hold of ggplot2 and ggvis packages and tried out shiny too to have interactive graphics and visualizations. but i have been using Power BI before and came to R as a an good ...
Vamsi Krishna's user avatar
1 vote
2 answers
11k views

How to summarize(add) a column according to same year and plot in R?

I have following type of data. But I would like to have graph with X-axis as Year and add all the sales added up in that year on Y- axis. The Data frame name is salesdata. I have nearly 8000 rows of ...
Ashok Kandipati's user avatar
0 votes
1 answer
3k views

Python: ggplot geom_histogram() binwidth or bin parameter missing?

I am unable to change number of bins when using geom_histogram() function. There is nothing in the documention, except some examples where binwidth=X is used (which is how R:ggplot2 uses it). However, ...
Andis's user avatar
  • 111
-2 votes
1 answer
499 views

How to get 2D-Array of boxplots without the diagonal with R (python also accepted)?

I want to do comparison between different factors with box plots. One factor doesn't compare with it self. So I need a matrix of boxplots (wich I could get using <...
dev93's user avatar
  • 105
6 votes
2 answers
694 views

Represent time-series data in much compact form

I have time series data of one month plotted day-wise as Notice every day follows a different pattern. Now, I want to show this "diversity in pattern" of each day in much compact form in a ...
Haroon Lone's user avatar
11 votes
2 answers
2k views

ggvis vs. ggplot2+Shiny; which one to choose for interactive visualization?

There is a similar question here in CrossValidated, and I have read the answers. My question is a bit different. I don't want to merely visualize my data, and indeed what I want to visualize is not ...
Shahin's user avatar
  • 271
3 votes
1 answer
236 views

R: lattice equivalent of density2d in ggplot?

What would be the equivalent of geom_density2d in lattice? In essence I'm trying to create this graph with lattice: I don't think contourplot or levelplot is what i want and when trying it, it gives ...
user3720596's user avatar
1 vote
1 answer
2k views

Manage x-axis using ggplot()

Source: https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2FNEI_data.zip Here is my data prep. ...
Drj's user avatar
  • 427