我想知道如何在solr配置中启用faceting而不必强制将其全部放在URL中.其次如何设置字段数?谢谢
我想创建一个多面线图。在每个子图中,将一个 y 值(y1 或 y2)与基线进行比较。y 值和基线应使用不同的颜色进行可视化,但此配色方案应在每个子图中保持一致。作为图例,我只需要 2 个条目:“y 值”和“基线”,因为每个子图的标题都指定了要比较的 y 值。
然而,我只得到这个(示例代码):
library(ggplot2)
library(reshape)
df = data.frame(c(10,20,40),c(0.1,0.2,0.3),c(0.1,0.4,0.5),c(0.05,0.1,0.2))
names(df)[1]="classes"
names(df)[2]="y1"
names(df)[3]="y2"
names(df)[4]="baseline"
df$classes <- factor(df$classes,levels=c(10,20,40), labels=c("10m","20m","40m"))
dfMelted <- melt(df)
diagram <- ggplot()
diagram <- diagram + theme_bw(base_size=16)
diagram <- diagram + geom_point(data=dfMelted, size=4, aes(x=factor(classes),y=value, colour=variable, shape=variable))
diagram <- diagram + geom_line(data=dfMelted, aes(x=factor(classes),y=value, group=variable, colour=variable))
diagram <- diagram + facet_wrap(~ variable, ncol=1)
diagram
Run Code Online (Sandbox Code Playgroud)
到目前为止,情况是这样的:
我尝试创建组,每个组包含一个 y 数据集和重复的基线数据。然后,我在组列方面使用了分面。不幸的是,这导致使用许多不同的颜色和巨大的图例。有没有更好的方法来做到这一点?
我正在根据样本类型(x轴)绘制Gene1计数(y轴)的等级.我希望根据它们的原始组织(乳房,结肠直肠,肺)和颜色代码对样本类型进行分组,无论它们分别来自癌症还是来自红色和绿色的正常组织.
我制作了图1)BOXPLOTS WITH FACETS(请参见下文),这与我的愿景很接近,但显示了一些主要问题.我在图表上有一些问题需要改进:
[IMG] http://i57.tinypic.com/10yfmmw.png [/ IMG ]
1)每个方面最终有9个车道(列),其中许多车道没有被箱子占据.如何删除每个方面中未被框占用的通道(列)?
2)我是否可以在不使用构面的情况下绘制此图形,同时仍保留图中所示的分组?
3)是否可以创建两个小平面标签?即我想在现有的facet标签上方放置标签"Gene1".这将使我能够为Gene2生成如下所示的相同图形,因此我可以使用每个图形顶部的"主"构面标签将两个图形彼此相邻.
我希望这是有道理的.谢谢大家的建议和想法.
请参阅以下代码,以便您下载我的数据并重现图表:
测试文件导入
fileURL <- "https://dl.dropboxusercontent.com/u/4098921/testfile.csv"
test <- read.csv(fileURL,header=T)
head(test)
> head(test)
Subset Tissue Type id Gene1 Gene2
1 Normal Breast GTEx_Breast 1 5027 12597
2 Normal Breast GTEx_Breast 2 5287 12338
3 Normal Breast GTEx_Breast 3 2385 12543
4 Normal Breast GTEx_Breast 4 3174 12266
5 Normal Breast GTEx_Breast 5 6593 11350
6 Normal Breast GTEx_Breast 6 4648 10932
Run Code Online (Sandbox Code Playgroud)
1)带有FACETS的BOXPLOT
library(ggplot2)
ggplot(test,aes(x=Type, y=Gene1, fill=Subset))+ …
Run Code Online (Sandbox Code Playgroud) 我在ggplot2中的各个方面注释文本时也遇到了一些麻烦(参考相关文章:ggplot2中的各个方面注释文本)。
数据框:
str(cfit_2)
'data.frame': 186 obs. of 5 variables:
$ Participant: Factor w/ 31 levels "2","3","4","5",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Condition : Factor w/ 2 levels "Active control group",..: 1 2 2 2 1 1 2 2 1 1 ...
$ Time : Factor w/ 2 levels "Pretest","Posttest": 1 1 1 1 1 1 1 1 1 1 ...
$ CFIT : num 10 13 17 11 19 15 19 …
Run Code Online (Sandbox Code Playgroud) 我想用ggplot绘制这些数据:
library(ggplot2)
set.seed(0)
df <- data.frame(
var1 = rep(c("group1", "group2"), each = 3),
var2 = rep(letters[1:3], 2),
value = runif(6, 0, 10)
)
Run Code Online (Sandbox Code Playgroud)
情节应该像这样:
pl <- ggplot(df, aes(var2, value))
pl <- pl + geom_col()
pl <- pl + facet_wrap(~ var1, scales = "free")
pl
Run Code Online (Sandbox Code Playgroud)
var2
x轴上的顺序应该通过增加的顺序来确定value
.我可以做到这一点:
df$temp_var <- paste(df$var1, df$var2)
pl <- ggplot(df, aes(reorder(temp_var, value), value))
pl <- pl + geom_col()
pl <- pl + facet_wrap(~ var1, scales = "free")
pl
Run Code Online (Sandbox Code Playgroud)
但是,x轴标签应该是a
,b
和c
.通常情况下,我会转换 …
我想使用ggarrange
(以使 x 轴对齐)排列两个刻面图。
library(egg)
library(ggplot2)
p1 <- ggplot(warpbreaks) +
geom_bar(aes(x = wool)) +
facet_wrap(~tension, ncol = 2, scales = "free_x") +
theme_bw() +
theme(axis.line = element_line(colour = "black", size = .1),
panel.border = element_blank(),
strip.background = element_blank())
p2 <- ggplot(warpbreaks) +
geom_bar(aes(x = tension)) +
facet_wrap(~wool) +
theme_bw() +
theme(axis.line = element_line(colour = "black", size = .1),
panel.border = element_blank(),
strip.background = element_blank())
ggarrange(p1, p2, ncol = 2)
Run Code Online (Sandbox Code Playgroud)
效果很好,但不幸的是垂直轴线消失了。使用 时不会发生这种情况grid.arrange
,但至少对于我的真实数据,x 轴未对齐,因此我希望使用ggarrange
. 有没有办法保持轴线?
我有代表两种方法的结果的箱线图,每种方法都有两种验证方法和三种场景,使用 ggplot2 绘制。一切正常,但我想更改 x 轴刻度标签以区分每个组中使用的技术类型。
我使用了以下代码:
data <- read.csv("results.csv", header = TRUE, sep=',')
ggplot() +
geom_boxplot(data = data, aes(x = Validation, y = Accuracy, fill = Scenario)) +
facet_wrap(~ Method) +
labs(fill = "")
Run Code Online (Sandbox Code Playgroud)
其中我的数据结构如下:
Method Validation Scenario Accuracy
-------------------------------------------------------
Method 1 Iterations Scenario 1 0.90
Method 1 Iterations Scenario 2 0.80
Method 1 Iterations Scenario 3 0.86
Method 1 Recursive Scenario 2 0.82
Method 2 Iterations Scenario 1 0.69
Method 2 Recursive Scenario 3 0.75
Run Code Online (Sandbox Code Playgroud)
并得到以下情节:
我只想将方法 1 和方法 …
我正在尝试使用下面的代码在 R 中绘制月度玫瑰图,但遇到错误:“错误:分面变量必须至少有一个值”
这是我使用的 数据链接到数据
此代码来自上一篇文章:使用 ggplot 的玫瑰图
require(ggplot2)
require(RColorBrewer)
require(scales)
plot.windrose <- function(data,
spd,
dir,
spdres = 2,
dirres = 22.5,
spdmin = 2,
spdmax = 20,
spdseq = NULL,
palette = "YlGnBu",
countmax = NA,
debug = 0){
# Look to see what data was passed in to the function
if (is.numeric(spd) & is.numeric(dir)){
# assume that we've been given vectors of the speed and direction vectors
data <- data.frame(spd = spd,
dir = dir)
spd = …
Run Code Online (Sandbox Code Playgroud) 我正在使用以下内容绘制一些数据,但是在完整样本中,数据有点难以看到,因为我在同一个图上有太多变量。如何将每个方面分成 2 个方面?也就是说,是否将变量的前半部分绘制在一条线上,将变量的后半部分绘制在第二条线上,但保留当前 4 个方面中的每一个?
由于字符限制删除了 ggplot 代码
数据:
structure(list(Status = structure(c(2L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, …
Run Code Online (Sandbox Code Playgroud) 我新安装了 Python 和 PyCharm,但无法在 PyCharm 中运行某些 Python 文件,因为在加载项目时会立即显示此错误。我不知道问题可能是什么,因为这似乎出现的唯一其他时间是尝试使用插件在 IntelliJ 中解释 Python 时,或者尝试在 PyCharm 中运行其他方面时。Python IDE 中的未知方面 Python 难倒了我。
facet ×10
ggplot2 ×8
r ×8
annotations ×1
boxplot ×1
pycharm ×1
python ×1
python-3.x ×1
rose-diagram ×1
solr ×1