- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用ggplot2创建了一个图。这与牛奶中的蛋白质含量有关。我有两组和4种治疗方法。我想展示组和处理,均值和错误栏之间的相互作用。蛋白质含量从2.6%开始。现在,我的y轴从那里开始没有间隙,但是我的主管希望有一个。
我尝试了plotrix库的axis.break(),但没有任何反应。我试图用gap.plot重建图形,但没有成功,但我必须承认我不是R英雄。
这是我的图形的代码:
Protein<-ggplot(data=D, aes(x=treat, y=Prot,group=group, shape=group))+
geom_line(aes(linetype=group), size=1, position=position_dodge(0.2))+
geom_point(size=3, position=position_dodge(0.2))+
geom_errorbar(aes(ymin=Prot-Prot_SD,ymax=Prot+Prot_SD), width=.2,
position=position_dodge(0.2))+
scale_shape_discrete(name='group\n', labels=c('1\n(n =
22,19,16,20)\n','2\n(n = 15,12,14,12)'))+
scale_linetype_discrete(name="group\n", labels=c('control\n(n =
22,19,16,20)\n','free-contact\n(n = 15,12,14,12)'))+
scale_x_discrete(labels=c('0', '1', '2', '3'))+
labs(x='\ntreatment', y='protein content (%)\n')
ProtStar<-Protein+annotate("text", x=c(1,2,3,4), y=c(3.25,3.25,3.25,3.25),
label=c("Aa","Aa","Ab","Ba"), size=4)
plot(ProtStar)
最佳答案
TL; DR:看底部。
考虑以下数字:
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic()
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic() +
scale_y_continuous(limits = c(0,NA), expand = c(0,0))
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic() +
scale_y_continuous(limits = c(0,NA), expand = c(0,0)) +
theme(axis.line.y = element_blank()) +
annotate(geom = "segment", x = -Inf, xend = -Inf, y = -Inf, yend = Inf)
annotate
手动绘制它。请注意,该图看起来与上一个相同。如果您选择的主题使用很多不同的大小,那么您将经历一段糟糕的时光。
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic() +
scale_y_continuous(limits = c(3.5,NA), expand = c(0,0),
breaks = c(3.5, 4:7)) +
theme(axis.line.y = element_blank()) +
annotate(geom = "segment", x = -Inf, xend = -Inf, y = -Inf, yend = Inf)
min(iris$Sepal.Length)
并考虑刻度线将移至何处。这是个人判断。
breaks = c(3.5, 4:7)
。
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic() +
scale_y_continuous(limits = c(3.5,NA), expand = c(0,0),
breaks = c(3.5, 4:7), labels = c(0, 4:7)) +
theme(axis.line.y = element_blank()) +
annotate(geom = "segment", x = -Inf, xend = -Inf, y = -Inf, yend = Inf)
labels = c(0, 4:7)
将3.5刻度重新标记为假零。
ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() +
theme_classic() +
scale_y_continuous(limits = c(3.5,NA), expand = c(0,0),
breaks = c(3.5, 4:7), labels = c(0, 4:7)) +
theme(axis.line.y = element_blank()) +
annotate(geom = "segment", x = -Inf, xend = -Inf, y = -Inf, yend = Inf) +
annotate(geom = "segment", x = -Inf, xend = -Inf, y = 3.5, yend = 4,
linetype = "dashed", color = "white")
关于r - axis.break和ggplot2或gap.plot?情节可能太复杂了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46403240/
我有这样一个数据框 from datetime import date import random start_date = date.today().replace(day=1, month=1).
我想使用 fiddle 图比较技术化的几个维度的分布(维度由 1 到 5 的指数衡量)。 6 个 fiddle 图中有 5 个看起来与您预期的一样,但其中一个具有未反射(reflect)在数据中的非常
我正在将向量列表绘制为一系列 fiddle 图。我会使用 pandas 数据框,但列表的长度不等。 这有效: python g = sns.violinplot (data=res, cut=0, i
以下代码为我提供了一个非常漂亮的 fiddle 图(以及其中的箱线图)。 import numpy as np import seaborn as sns import matplotlib.pypl
我有以下代码来显示堆叠条 handles = df.toPandas().set_index('x').T.plot(kind='bar', stacked=True, figsize=(11,11)
目前我在 2x2 子图中绘制了 3 个图。它看起来像这样: fig, axes = plt.subplots(nrows=2, ncols=2) df1.plot('type_of_plot', ax
以下代码为我提供了一个非常漂亮的 fiddle 图(以及其中的箱线图)。 import numpy as np import seaborn as sns import matplotlib.pypl
我正在使用带有以下代码的 ggplot 的 python 版本并附加了图像,但颜色不足以为所有类别着色。我想知道有什么方法可以获得具有更多颜色的调色板,但仍然保留较低数字颜色较浅而较高数字颜色较深的关
我正在查看示例,但一切都需要数据框。 如果我有以下数据框: x = ["G","F","E","D","C","B"] y = [3,14,45,47,34,15] df = pd.DataFrame
我有很多数据框正在绘制用于演示。这些都有不同的列,但都包含相同的附加列 foobar。目前,我正在使用绘制这些不同的数据框 df.plot(secondary_y='foobar') 不幸的是,由于这
我无法让 Bokeh 显示我的绘图。这是我的 Python 代码。 import pandas as pd from bokeh.plotting import figure, ColumnDataS
我使用 matplot 库在 python 中绘制绘图。我必须生成的数字非常大,所以轴上的刻度也是很大的数字并且占用大量空间。我试图将它们呈现为幂(例如,我想要 10^8 而不是勾选 10000000
我使用 matplot 库在 python 中绘制绘图。我必须生成的数字非常大,所以轴上的刻度也是很大的数字并且占用大量空间。我试图将它们呈现为幂(例如,我想要 10^8 而不是勾选 10000000
我只想制作一个地毯图,其中每个系列都被绘制为水平的刻度带,类似于所示的图 on this page .我也见过这叫做“光栅图”。地毯图看起来很相似,但看起来 geom_rug 只适用于边距。我可以在
我正在使用此处示例中的代码绘制一个图: http://bl.ocks.org/mbostock/3887118 我是 HTML、CSS 和 JS 的新手,但了解一些基础知识。我想知道如何将绘图置于浏览
有一个 df : import random import pandas as pd def get_row(): row = {"date" : random.choice(range(10
第一个加载的绘图在 X 轴上有太多刻度(参见 image01)。 如果我在 X 轴上使用缩放操作,绘图现在已加载完毕。 你能给我一些建议,我可以在哪里搜索,因为 Plot 构造函数参数看起来不错。 d
我正在尝试为我的情节添加标题,但收到错误消息: "AttributeError: 'Figure' object has no attribute 'update_layout'" 该情节在没有 up
我想在 python 中使用 networkx 绘制有向网络图。当使用不同于 1 的 alpha 值时,边缘的起点也在节点内绘制;但是箭头很好。 如何让边远离我的节点? 我没有在文档中找到任何关于它的
出于视觉效果的目的,我希望我可以删除圆圈外的网格,只保留圆圈内的网格。 顺便说一句,如何用红色填充单元格 ([8,9],[9,10]),我的意思是,x=8 右侧和 y=9 下方的单元格。 我的代码在下
我是一名优秀的程序员,十分优秀!