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.
45 questions
0
votes
1
answer
47
views
Learning material for R
I am looking for learning material for R (including base R & tidyverse approaches (with a focus on readr, dplyr & tidyr)) and data visualisation using ggplot2 library for commercial teaching ...
0
votes
1
answer
141
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 ...
0
votes
1
answer
6k
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:
<...
1
vote
1
answer
582
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:
...
1
vote
0
answers
82
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:
...
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 ...
2
votes
0
answers
481
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 ...
1
vote
1
answer
62
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 ...
1
vote
1
answer
209
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?
...
1
vote
1
answer
172
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.
...
0
votes
1
answer
2k
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 ...
0
votes
1
answer
2k
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 ...
1
vote
1
answer
669
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 ...
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:
...
2
votes
0
answers
867
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 ...
2
votes
1
answer
434
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 ...
1
vote
1
answer
65
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 ...
3
votes
1
answer
537
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. ...
1
vote
1
answer
181
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 ...
2
votes
1
answer
301
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 ...
0
votes
1
answer
95
views
How to create a barplot using multiple column [closed]
My data is about boardgames which contain 1 to many catgeories each like this :
...
2
votes
3
answers
79
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 ...
2
votes
1
answer
5k
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
...
0
votes
0
answers
6k
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 ...
5
votes
1
answer
53k
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
...
1
vote
2
answers
339
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 ...
0
votes
1
answer
722
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 ...
1
vote
1
answer
209
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.
...
3
votes
1
answer
277
views
ggplot (in R)/matplotlib (in Python) with linear model?
How can I plot the histogram below, using ggplot (R) and/or matplotlib (...
1
vote
1
answer
541
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 ...
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.
...
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 ...
-1
votes
2
answers
164
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 ...
1
vote
0
answers
33
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. ...
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 & ...
1
vote
0
answers
53
views
Infoviz for multinomials: miniature plots within plots in R's ggplot
I'm plotting fluctuations in a trinomial distribution across two dimensions.
...
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:
...
0
votes
1
answer
199
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 ...
2
votes
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 ...
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, ...
-2
votes
1
answer
535
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 <...
6
votes
2
answers
743
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 ...
11
votes
2
answers
3k
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 ...
4
votes
1
answer
257
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 ...
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.
...