如何使绘图从零开始?(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 at0
and end at10
instead of10.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")
原文:https://stackoverflow.com/questions/45971069
更新时间:2024-01-04 19:01
最满意答案
'ImageFormat' ,而不是Imageformat,它区分大小写。
'ImageFormat', not Imageformat, it is case-sensitive.
相关问答
更多-
您有.NET Standard的包。 我相信你需要适用于UWP的.NET Core软件包。 Microsoft.Azure.DocumentDB.Core v 1.7.1 请注意, Microsoft.Azure.DocumentDB.Core 1.7.1软件包与Windows 10 Fall Creators Update之前的版本不兼容。 因此,您应该为您的项目将Target和最低版本都设置为Windows 10 Fall Creator Update Build 16299。 You have the ...
-
'ImageFormat' ,而不是Imageformat,它区分大小写。 'ImageFormat', not Imageformat, it is case-sensitive.
-
几个月前我面临同样的问题。 问题在于两个项目都没有针对相同的平台 ,即控制台应用程序针对.Net framework 4.0 Client Profile而该库的目标是full .Net framework 4.0 。 通过针对两个项目的完整.Net 4.0框架进行修复。 I faced same issue some months ago. The problem was both projects didn't target the same platform, i.e. the console app ...
-
如果其他人有兴趣,我已经发现了这个问题的答案。 在我的主应用程序中,我以.NET Framework 4 Client Profile为目标,但在其中一个引用的程序集中,我将目标定位到完整的.net框架。 虽然intellisense和Visual Studio本身不报告问题,但编译器会抛出错误。 不是与目标框架有关的错误,只是与我的命名空间相关的“类型或命名空间不存在”错误,而不是框架的客户端配置文件版本中缺少的错误。 埃德 I have discovered the answer to this pro ...
-
确保您的项目引用 Microsoft.Practices.EnterpriseLibrary.Common Microsoft.Practices.EnterpriseLibrary.Data Be sure that your project is referencing to Microsoft.Practices.EnterpriseLibrary.Common Microsoft.Practices.EnterpriseLibrary.Data
-
类型或命名空间名称“DataServiceKeyAttribute”不存在(The type or namespace name 'DataServiceKeyAttribute' does not exist)[2021-11-07]
此类型在.NET Framework程序集Microsoft.Data.Services.Client定义。 确保项目引用此程序集,它应该可以正常工作。 This Type is defined in the .NET Framework Assembly Microsoft.Data.Services.Client. Ensure that this assembly is referenced by your project and it should work fine. -
使用NHibernate 4,在大多数情况下,您不再需要明确依赖Iesi 。 您应该迁移实体代码以使用System.Collections.Generic.ISet
。 这就是我所做的,甚至在遇到Iesi的任何问题之前。 如果你想继续使用Iesi,你可以通过提供你自己的NHibernate.Bytecode.ICollectionTypeFactory和可选的设置 collectiontype.factory_class来做到这一点。 但我不认为这是值得的麻烦。 发行说明 ,“**从NH3.3.3.G ... -
类型或命名空间名称“DataServiceQuerySingle”不存在(The type or namespace name 'DataServiceQuerySingle' does not exist)[2023-05-10]
我还不确定该怎么做。 我通过删除某人实际手动包含在解决方案中的库并修复了nuget包来修复了我的一些问题。 我想我最后只需要使用HttpClient手动调用odata服务。 总的来说我的解决方案有效,但我对它并不满意。 I'm not sure what to do about this, still. I fixed some of my problems by removing libraries that someone had actually manually included in the so ... -
回过头来完成我对TFS的工作后,我设法解决了我所做的创建了这个错误的事情:我在项目中添加了一个名为“System”的文件夹,并在其中添加了一个类文件。 这是一个容易重现的问题:创建一个项目,向它添加一个名为system的文件夹(此时它仍然会编译),然后在其中创建一个.cs文件,这就是所有有趣的错误都会发生的时候。 问题源于“System”文件夹的名称,该文件夹导致在其中创建的任何文件位于名称空间“.System”下。 我可以理解为什么有一个名为“System”的文件夹/命名空间现在会引起问题,但我认为如果V ...
-
名称空间“系统”中不存在类型或命名空间名称“计时器”(The type or namespace name 'Timers' does not exist in the namespace 'system')[2022-10-12]
由于你不是很分享我创建了一个测试项目。 PCL(可移植类库)项目。 我刚刚采用了所有平台,包括Silverlight 5。 当我添加你正在谈论的using ,确实说命名空间不存在。 所以似乎你有一个不支持System.Timers的项目类型。 实际上,为了支持Guffa删除System程序集的假设 ,它也提供了完全相同的错误消息。 Since you are not very sharing I created a test project. A PCL (Portable Class Library) p ...