ggplot2

ggplot2 Heatmap 2 Different Color Schemes - Confusion Matrix: Matches in Different Color Scheme than Missclassifications

自作多情 提交于 2021-02-11 05:54:18
问题 I adapted a heatmap plot for a confusion matrix from this answer. However I would like to twist it. In the diagonal (from top left to bottom right) are the matches (correct classifications). My aim would be, to plot this diagonal in a yellow color palette. And mismatches (so all tiles except those in the diagonal) in a red color palette. In my plot.cm function I can get the diagonal with cm_d$diag <- cm_d$Prediction == cm_d$Reference # Get the Diagonal cm_d$ndiag <- cm_d$Prediction != cm_d

Labeling: Facet grid with multiple lines of text on y label

℡╲_俬逩灬. 提交于 2021-02-11 04:58:39
问题 I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible? majors.sub.HS<- majors.sub[, c(8:10, 66)] majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" ) majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5 majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

Unfilled area in ggplot geom_area

我是研究僧i 提交于 2021-02-11 04:58:24
问题 I'm trying to do a plot with ggplot2 and geom_area . The fill is set by a variable. For some reason, only the 'outer' groups are filled. I can't figure out how to get the inner regions filled as well. The same problem seems to occur here but no answer is given on how to solve it. Below is an minimal example of the code i'm using and the resulting plot: I'm using R 3.3 and ggplot2_2.1.0 Any help would be appreciated. df <- data.frame(month = seq(from = as.Date("2016-01-01"), to = as.Date("2016

Labeling: Facet grid with multiple lines of text on y label

≡放荡痞女 提交于 2021-02-11 04:56:14
问题 I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible? majors.sub.HS<- majors.sub[, c(8:10, 66)] majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" ) majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5 majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

R ggplot stacked geom_rect

落爺英雄遲暮 提交于 2021-02-11 04:54:56
问题 I would like to draw a bar chart with ggplot where I adjust the width of the bars. I have found an example here which works perfectly fine. But instead of one bar per row in the data frame I would like to make a stacked bar of 2 to 4 columns. Here is the code of the original: library(ggplot2) # make data data=data.frame(group=c("A ","B ","C ","D ") , value=c(33,62,56,67) , number_of_obs=c(100,500,459,342)) # Calculate the future positions on the x axis of each bar (left border, central

R ggplot stacked geom_rect

ぃ、小莉子 提交于 2021-02-11 04:54:30
问题 I would like to draw a bar chart with ggplot where I adjust the width of the bars. I have found an example here which works perfectly fine. But instead of one bar per row in the data frame I would like to make a stacked bar of 2 to 4 columns. Here is the code of the original: library(ggplot2) # make data data=data.frame(group=c("A ","B ","C ","D ") , value=c(33,62,56,67) , number_of_obs=c(100,500,459,342)) # Calculate the future positions on the x axis of each bar (left border, central

ggplot2 R fix x-axis label at a specific point relative to plot

一世执手 提交于 2021-02-11 04:28:09
问题 Say I have a plot like this: library(ggplot2) dat <- data.frame(x = 1:10, y = 1:10) ggplot(dat, aes(x = x, y = y)) + geom_point() + xlab("Test label") Does ggplot2 allow for fixing the xlab positioning at a specific point? Say I wanted the label to appear centered at the point where x = 7 (rather than the default centering). 回答1: This isn't exactly what you want, but you can adjust the horizontal justification in the theme options. This is relative between 0 and 1, not tied to the data

How to make a graph of clustered boolean variables in R?

拈花ヽ惹草 提交于 2021-02-11 04:27:35
问题 I have a dataset which consists entirely of boolean variables. Exactly like the transformed animal dataset below, only with many more columns. # http://stats.stackexchange.com/questions/27323/cluster-analysis-of-boolean-vectors-in-r library(cluster) head(mona(animals)[[1]]) war fly ver end gro hai ant 0 0 0 0 1 0 bee 0 1 0 0 1 1 cat 1 0 1 0 0 1 cpl 0 0 0 0 0 1 chi 1 0 1 1 1 1 cow 1 0 1 0 1 1 The goal is to rearrange the rows in such a way that groupings of similar membership patterns are

How to make a graph of clustered boolean variables in R?

喜夏-厌秋 提交于 2021-02-11 04:26:19
问题 I have a dataset which consists entirely of boolean variables. Exactly like the transformed animal dataset below, only with many more columns. # http://stats.stackexchange.com/questions/27323/cluster-analysis-of-boolean-vectors-in-r library(cluster) head(mona(animals)[[1]]) war fly ver end gro hai ant 0 0 0 0 1 0 bee 0 1 0 0 1 1 cat 1 0 1 0 0 1 cpl 0 0 0 0 0 1 chi 1 0 1 1 1 1 cow 1 0 1 0 1 1 The goal is to rearrange the rows in such a way that groupings of similar membership patterns are

How to make a graph of clustered boolean variables in R?

眉间皱痕 提交于 2021-02-11 04:25:59
问题 I have a dataset which consists entirely of boolean variables. Exactly like the transformed animal dataset below, only with many more columns. # http://stats.stackexchange.com/questions/27323/cluster-analysis-of-boolean-vectors-in-r library(cluster) head(mona(animals)[[1]]) war fly ver end gro hai ant 0 0 0 0 1 0 bee 0 1 0 0 1 1 cat 1 0 1 0 0 1 cpl 0 0 0 0 0 1 chi 1 0 1 1 1 1 cow 1 0 1 0 1 1 The goal is to rearrange the rows in such a way that groupings of similar membership patterns are