- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制作了一个存储在名为 ggplots
的对象中的 g.a
列表,这是重现绘图的代码(数据在底部提供)。
值得一提的是,我可能遗漏了一些简单且过于复杂的问题。
RCfitter <- function(w,h,a,b){(a * ((w + h)^b))}
fillfactor <- lapply(seq_len(length(dat.a)), function(i) {
as.factor((gsub("-.*","",dat.a[[i]]$Date)))}) #I tried as.integer as well
set.seed(92)
lin.a <- lapply(seq_len(length(dat.a)), function(i) {
data.frame(x = runif(100, -dB.coef.a[3,i],
max(dat.a[[i]]$WL)+diff(0.2*range(dat.a[[i]]$Q))))})
library(ggplot2)
g.a <- lapply(seq_len(length(dat.a)), function(i) {
ggplot() +
geom_point(data=dat.a[[i]], aes(x=WL,y=Q, tltip = Date,
fill =fillfactor[[i]]),
colour = NA, pch=21) +
scale_fill_manual(breaks = mybreaks, values = myfills)+
geom_line(data = lin.a[[i]],
aes(x=x,y= RCfitter(x,dB.coef.a[3,i],dB.coef.a[1,i],dB.coef.a[2,i])),colour="red")+
xlab("WL") +
ylab("Q") +
ggtitle(paste("pLot ",i)) +
ylim(c(0,(max(dat.a[[i]]$Q)+diff(0.2*range(dat.a[[i]]$Q))))) +
xlim(c(0,(max(dat.a[[i]]$WL)+diff(0.2*range(dat.a[[i]]$WL))))) +
theme(legend.position="none")
})
如果我忽略
scale_fill
我可以绘制它们,我会得到“彩色”图。但是我收到了这个警告:
g.a[[2]]
## Warning messages:
## 1: Removed 6 rows containing missing values (geom_point).
## 2: Removed 64 rows containing missing values (geom_path).
这意味着
geom_point
不绘制任何内容。
scale_fill_discrete
、
scale_fill_continuous
等,它们给了我类似
discrete value to continuous scale
或反之亦然的错误。
ggplotly()
(例如
ggplotly(g.a[[2]],tooltip = c("x","y","tltip")
)。因此,如果这会改变
scale_fill
的行为(例如,我指定的某些颜色对
plotly
无效),请记住这一点。
dat.a
dat.a <- list(structure(list(Date = c("1974-02-14", "1974-02-16", "1974-02-28",
"1974-02-28", "1974-02-28", "1974-02-28"), WL = c(0.24, 0.135,
0.395, 0.26, 0.22, 0.31), Q = c(0.237, 0.04, 0.9, 0.36, 0.52,
0.56), Velocity = c(0.3, 0.103, 0.367, 0.209, 0.34, 0.276), Area = c(0.79,
0.388, 2.452, 1.722, 1.529, 2.029), Flag = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_),
Shift = c("/", "/", "/", "/", "/", "/"), date = structure(c(130032000,
130204800, 131241600, 131241600, 131241600, 131241600), class = c("POSIXct",
"POSIXt"), tzone = "UTC")), .Names = c("Date", "WL", "Q",
"Velocity", "Area", "Flag", "Shift", "date"), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame")), structure(list(
Date = c("1965-01-29", "1965-01-29", "1965-04-25", "1966-11-29",
"1967-01-24", "1967-11-12"), WL = c(0.439, 0.439, 0.482,
0.463, 0.427, 0.475), Q = c(0.252, 0.269, 0.403, 0.314, 0.199,
0.4), Velocity = c(0.23, 0.232, 0.316, 0.279, 0.249, 0.36
), Area = c(1.096, 1.159, 1.275, 1.125, 0.799, 1.111), Flag = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Shift = c("/", "/", "/", "/", "/", "/"),
date = structure(c(-155347200, -155347200, -147916800, -97545600,
-92707200, -67478400), class = c("POSIXct", "POSIXt"), tzone = "UTC")),
.Names = c("Date","WL", "Q", "Velocity", "Area", "Flag", "Shift", "date"),
row.names = c(NA,-6L), class = c("tbl_df", "tbl", "data.frame")))
dB.coef.a
dB.coef.a <- structure(c(-77.6915945552795, 0.594614568300253, 60.9718752625543,
7.96297849987566, 2.69599957356069, -0.183937755444007), .Dim = c(3L,
2L), .Dimnames = list(c("a", "b", "h"), NULL))
mybreaks
mybreaks <- c(1955, 1956, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966,
1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977,
1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988,
1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017)
myfills
myfills <- c("005ABF", "0358BC", "0757B9", "0A56B6", "0E54B3", "1153B0",
"1552AD", "1851AA", "1C4FA7", "1F4EA4", "234DA2", "264B9F", "2A4A9C",
"2D4999", "314896", "344693", "384590", "3B448D", "3F428A", "424187",
"464085", "493F82", "4D3D7F", "503C7C", "543B79", "573976", "5B3873",
"5E3770", "62366D", "65346A", "693368", "6D3265", "703062", "742F5F",
"772E5C", "7B2D59", "7E2B56", "822A53", "852950", "89274D", "8C264B",
"902548", "932445", "972242", "9A213F", "9E203C", "A11E39", "A51D36",
"A81C33", "AC1B30", "AF192E", "B3182B", "B61728", "BA1525", "BD1422",
"C1131F", "C4121C", "C81019", "CB0F16", "CF0E13", "D30D11")
最佳答案
一个建议,如果我正确理解你的问题:
1. 我有一 strip 有颜色的错误消息( myfills
):
Error in grDevices::col2rgb(colour, TRUE)
#
不见了 :
mycolors <- paste0("#", myfills) # correct colors
names(mycolors ) <- mybreaks # name your colors
mycolors[names(mycolors) == "1965"] <- "#D30D11" # swapped color to red to check its ok
pch = 21
为
geom_point
,更好用
pch = 16
,然后忘记
fill
美观与使用
color
反而 :
g.a <- lapply(seq_len(length(dat.a)), function(i) {
ggplot(data = dat.a[[i]], aes(x = WL, y = Q, color = fillfactor[[i]])) +
geom_point(pch = 16) +
scale_color_manual(values = mycolors) +
geom_line(data = lin.a[[i]], aes(x = x, y = RCfitter(x, dB.coef.a[3,i], dB.coef.a[1,i], dB.coef.a[2,i])), colour = "red") +
ggtitle(paste("pLot ",i)) +
ylim(c(0,(max(dat.a[[i]]$Q) + diff(0.2*range(dat.a[[i]]$Q))))) +
xlim(c(0,(max(dat.a[[i]]$WL) + diff(0.2*range(dat.a[[i]]$WL))))) +
theme(legend.position="none")
}
)
g.a[[2]]
geom_path
的警告消息是由于您的
xlim()
.
关于r - ggplot2 中的 scale_fill - 为 ggplots 列表中的每个图制作渐变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47686022/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!