我正在绘制hovmoller三个栅格的图,但该函数在 x 轴上绘制纬度,在 y 轴上绘制时间。通常(更容易阅读)纬度位于 Y 轴上。可重现的例子:
library("rasterVis")
r <- raster(nrows=10, ncols=10)
r <- setValues(r, 1:ncell(r))
r1 <- raster(nrows=10, ncols=10)
r1 <- setValues(r1, 1:ncell(r))
r2 <- raster(nrows=10, ncols=10)
r2 <- setValues(r2, 1:ncell(r))
St=stack(r,r1,r2)
idx <- seq(as.Date('2008-01-15'), as.Date('2008-1-17'), 'day')
SISmm <- setZ(St, idx)
hovmoller(SISmm, contour=FALSE, panel=panel.levelplot.raster,
yscale.components=yscale.raster.subticks,
interpolate=TRUE, par.settings=RdBuTheme)
Run Code Online (Sandbox Code Playgroud)
这会产生:
所以我希望时间在 X 轴上,纬度在 Y 轴上!
我在 R 中遇到问题,非常感谢您的帮助。
我必须针对以下约束绘制可行性区域:
constrains:
5*x + 3*y >= 210
x + y <= 110
4*x + y <= 200
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我还需要为可行的区域着色。
我不确定这是否是源代码的一个小错误,但子图不会分散绘制两个形状为 (1018,) 的数组。这两个数组都是 OLS 回归的结果。在使用指定的子图命令之前,我在使用变量执行散点图时从未遇到过问题。下面是我的代码:
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(12,5))
axes[0,0].scatter(Blodgett_wue_obs,Blodgett_wue_results.fittedvalues,color ='blue')
axes[0,0].plot(Blodgett_wue_obs,Blodgett_wue_obs,'r')
File "<ipython-input-311-527571e09d59>", line 1, in <module>
runfile('/Users/JasonDucker/Documents/forJason/Paper_Plots.py', wdir='/Users/JasonDucker/Documents/forJason')
File "/Users/JasonDucker/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/Users/JasonDucker/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 78, in execfile
builtins.execfile(filename, *where)
File "/Users/JasonDucker/Documents/forJason/Paper_Plots.py", line 362, in <module>
axes[0,0].scatter(Blodgett_wue_obs,Blodgett_wue_results.fittedvalues,color ='blue')
IndexError: too many indices for array
Run Code Online (Sandbox Code Playgroud)
关于这个问题的任何想法将不胜感激!
我想像这篇文章一样在彼此之上绘制两个图表在彼此之上绘制两个图表。
\n\n实验数据:我有一个连续变量,在名为 的列表中显示给定日期的风角expt$iso_xs[,8],然后我在 中具有与该角度相对应的风速expt$iso_xs[,2]。
df<-data.frame(expt$iso.xs)\n\nhead(expt$iso.xs)\n [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]\n 736105.4 16.62729 2.183740 7.234774 0.9791632 4.01 4.20 238.62\n 736105.4 18.96705 2.489668 7.036234 0.9640366 3.82 4.00 243.14\n 736105.5 20.52089 2.687636 10.355394 1.3698454 4.99 5.14 247.02\n 736105.5 19.94449 2.611556 10.306912 1.3655301 4.85 5.12 249.57\n 736105.5 19.43309 2.551787 11.098302 1.4646251 4.83 5.12 243.89\n 736105.5 20.48259 2.689075 11.928011 1.5710530 4.89 5.09 254.23\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n模拟数据:我有一个 data.frame z,其中包含上述角度的子集 (0-90\xc2\xba) 的预测。 …
我正在尝试将多个数据框放在一个线图中,使用x = index, y = values。我使用的 8 个 data.frames 采用这种格式(索引和值),并且有数百行长:
Values
2306 0.000000
2307 1.004711
Run Code Online (Sandbox Code Playgroud)
因为数据框并不都具有相同的大小,所以我还尝试通过将数据集转换为百分比(索引/值总数)*100 来调整数据集的大小,我应该将其放在绘图代码中还是应该更好在绘图之前转换数据集?
希望 StackOverflow 的 hivemind 能够帮助 R 新手
与我们在 MATLAB 中使用 subplot 命令在单个图中绘制多个图类似,如何使用 Simulink 在同一图中绘制不同的图?
笔记:
有什么帮助吗?
我将 Plots.jl 与 GR 后端一起使用。
无论如何,我似乎无法策划!在 for 循环内:
using Plots
fn(m,x) = m*x
plot([0, 10], [fn(1, 0), fn(1, 10)])
for m in 2:4
plot!([0, 10], [fn(m, 0), fn(m, 10)])
end
Run Code Online (Sandbox Code Playgroud)
奇怪的是,不使用循环也能实现同样的效果:
using Plots
fn(m,x) = m*x
plot([0, 10], [fn(1, 0), fn(1, 10)])
plot!([0, 10], [fn(2, 0), fn(2, 10)])
plot!([0, 10], [fn(3, 0), fn(3, 10)])
plot!([0, 10], [fn(4, 0), fn(4, 10)])
Run Code Online (Sandbox Code Playgroud)
我想push!()在 for 循环中使用来继续两条单独的绘图线。考虑以下示例:
using Plots; gr()
f = x->x*x
g = x->f(x)+.2*randn()
p = plot(-1:.1:0, f, ylim=(-1,2), c=:blue)
s = scatter!(-1:.1:0, g, c=:red)
anim = Animation()
for i=1:10
x = i/10
push!(p, x, f(x))
push!(s, x, g(x)) # without this, f gets continued as expected
frame(anim)
end
gif(anim, "test.gif", fps=2)
Run Code Online (Sandbox Code Playgroud)
为什么push!(p, ...)和push!(s,...)两者都继续蓝线?如何将分散的数据附加到s?
我知道此链接的第二个图通过同时绘制和推动两条线获得了类似的结果,但该解决方案并不总是实用的,尤其是在更复杂的图中。
是否可以使用 Julia Plots 包重现此图? 使用 gnuplot 绘图
x = y = -15:0.4:15
f1 = (x,y) -> @. sin(sqrt(x*x+y*y))/sqrt(x*x+y*y)
surf(x, y, f1, w = :p, marker = "dot", Axes(hidden3d = :on))
Run Code Online (Sandbox Code Playgroud)
你能帮我如何在我的 R 图表中添加数据标签吗
date = c(1.45,0.89,0.74,3.28)
plot(date,type = "l")
Run Code Online (Sandbox Code Playgroud)
我需要显示百分比