首页 \ 问答 \ 如何使绘图从零开始?(How can I make the plot start at zero?)

如何使绘图从零开始?(How can I make the plot start at zero?)

我有一个数据框,我从中创建一个二维图,填充来自第三列。

ggplot(a, aes(x=time, y=Layer, fill = Value))+
  geom_tile()+
  scale_fill_gradient2(low="blue",mid="yellow",high="red", midpoint=0.5)+
  theme_bw()

现在, Layer范围是1-10,但是当我绘制时,geom_tile从中点开始。 如何让它从0开始到10而不是10.5结束?

dput(a)中

structure(list(Layer = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L), mLayerVolFracLiq = c(0.363718066074495, 0.363933384428794, 
0.364400746014017, 0.365175162266439, 0.366478613460277, 0.367862103805244, 
0.369580612135753, 0.371329557433169, 0.272431415602475, 0.327468643048551, 
0.327897896730601, 0.32856502757375, 0.329595993919462, 0.330599478658051, 
0.331763769119895, 0.332889478379646, 0.239569037788007, 0.317540647774584, 
0.322494562891295, 0.323358879198933, 0.324561654946114, 0.325586756470287, 
0.326653284285629, 0.327532833630272, 0.261175199102923, 0.301400809191216, 
0.321074149620943, 0.321607194199411, 0.322388735750387, 0.323056962371599, 
0.323757666857778, 0.32442138598775, 0.312212741188763, 0.324776654481821, 
0.324768151152297, 0.324756637490834, 0.324726976153914, 0.324618664763349, 
0.32433134053386, 0.323817044326496, 0.251971636137293, 0.320441574804528, 
0.321595054735562, 0.32290107949736, 0.324310319642686, 0.325122235790138, 
0.325603020063082, 0.325372562796669, 1.73807585576703e-07, 1.01045675059099e-06, 
0.254757797872636, 0.268074882490628, 0.319964072649761, 0.32034002493773, 
0.320900756641409, 0.321453528320185, 0.322177257826123, 0.323115274003383, 
1.24486825410929e-07, 6.25566160415274e-07, 0.242701604730622, 
0.259436929276621, 0.317826642868764, 0.318457767194441, 0.319300660275628, 
0.320020661370089, 0.320835746922608, 0.32167722625929, 1.87615579711712e-07, 
7.44971438115926e-07, 0.237228459751742, 0.249074201814969, 0.315716905648282, 
0.31707145209583, 0.31798052983471, 0.318739416082674, 0.319620457203197, 
0.320534849645649, 6.89365505790602e-07, 2.05727270325164e-06, 
0.241335088464608, 0.25061601558339, 0.310690297750807, 0.316451528382204, 
0.317123994951979, 0.317784575834729, 0.318651454537485, 0.319589121434301
), time = structure(c(17146, 17146, 17146, 17146, 17146, 17146, 
17146, 17146, 17147, 17147, 17147, 17147, 17147, 17147, 17147, 
17147, 17148, 17148, 17148, 17148, 17148, 17148, 17148, 17148, 
17149, 17149, 17149, 17149, 17149, 17149, 17149, 17149, 17150, 
17150, 17150, 17150, 17150, 17150, 17150, 17150, 17151, 17151, 
17151, 17151, 17151, 17151, 17151, 17151, 17152, 17152, 17152, 
17152, 17152, 17152, 17152, 17152, 17152, 17152, 17153, 17153, 
17153, 17153, 17153, 17153, 17153, 17153, 17153, 17153, 17154, 
17154, 17154, 17154, 17154, 17154, 17154, 17154, 17154, 17154, 
17155, 17155, 17155, 17155, 17155, 17155, 17155, 17155, 17155, 
17155), class = "Date")), row.names = c(NA, -88L), .Names = c("Layer", 
"Value", "time"), class = "data.frame")

在此处输入图像描述


I have a dataframe from which I am creating a 2-D plot where fill is from a third column.

ggplot(a, aes(x=time, y=Layer, fill = Value))+
  geom_tile()+
  scale_fill_gradient2(low="blue",mid="yellow",high="red", midpoint=0.5)+
  theme_bw()

Now, Layer range is 1-10, but when I plot, the geom_tile starts from midpoint. How can I make it start at 0 and end at 10 instead of 10.5?

dput(a)

structure(list(Layer = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L), mLayerVolFracLiq = c(0.363718066074495, 0.363933384428794, 
0.364400746014017, 0.365175162266439, 0.366478613460277, 0.367862103805244, 
0.369580612135753, 0.371329557433169, 0.272431415602475, 0.327468643048551, 
0.327897896730601, 0.32856502757375, 0.329595993919462, 0.330599478658051, 
0.331763769119895, 0.332889478379646, 0.239569037788007, 0.317540647774584, 
0.322494562891295, 0.323358879198933, 0.324561654946114, 0.325586756470287, 
0.326653284285629, 0.327532833630272, 0.261175199102923, 0.301400809191216, 
0.321074149620943, 0.321607194199411, 0.322388735750387, 0.323056962371599, 
0.323757666857778, 0.32442138598775, 0.312212741188763, 0.324776654481821, 
0.324768151152297, 0.324756637490834, 0.324726976153914, 0.324618664763349, 
0.32433134053386, 0.323817044326496, 0.251971636137293, 0.320441574804528, 
0.321595054735562, 0.32290107949736, 0.324310319642686, 0.325122235790138, 
0.325603020063082, 0.325372562796669, 1.73807585576703e-07, 1.01045675059099e-06, 
0.254757797872636, 0.268074882490628, 0.319964072649761, 0.32034002493773, 
0.320900756641409, 0.321453528320185, 0.322177257826123, 0.323115274003383, 
1.24486825410929e-07, 6.25566160415274e-07, 0.242701604730622, 
0.259436929276621, 0.317826642868764, 0.318457767194441, 0.319300660275628, 
0.320020661370089, 0.320835746922608, 0.32167722625929, 1.87615579711712e-07, 
7.44971438115926e-07, 0.237228459751742, 0.249074201814969, 0.315716905648282, 
0.31707145209583, 0.31798052983471, 0.318739416082674, 0.319620457203197, 
0.320534849645649, 6.89365505790602e-07, 2.05727270325164e-06, 
0.241335088464608, 0.25061601558339, 0.310690297750807, 0.316451528382204, 
0.317123994951979, 0.317784575834729, 0.318651454537485, 0.319589121434301
), time = structure(c(17146, 17146, 17146, 17146, 17146, 17146, 
17146, 17146, 17147, 17147, 17147, 17147, 17147, 17147, 17147, 
17147, 17148, 17148, 17148, 17148, 17148, 17148, 17148, 17148, 
17149, 17149, 17149, 17149, 17149, 17149, 17149, 17149, 17150, 
17150, 17150, 17150, 17150, 17150, 17150, 17150, 17151, 17151, 
17151, 17151, 17151, 17151, 17151, 17151, 17152, 17152, 17152, 
17152, 17152, 17152, 17152, 17152, 17152, 17152, 17153, 17153, 
17153, 17153, 17153, 17153, 17153, 17153, 17153, 17153, 17154, 
17154, 17154, 17154, 17154, 17154, 17154, 17154, 17154, 17154, 
17155, 17155, 17155, 17155, 17155, 17155, 17155, 17155, 17155, 
17155), class = "Date")), row.names = c(NA, -88L), .Names = c("Layer", 
"Value", "time"), class = "data.frame")

enter image description here


原文:https://stackoverflow.com/questions/45971069
更新时间:2024-01-04 19:01

最满意答案

'ImageFormat' ,而不是Imageformat,它区分大小写。


'ImageFormat', not Imageformat, it is case-sensitive.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。