我很迷惑.在标题,标签和绘图的其他位置增加文本字体大小的正确方法是什么?
例如
x <- rnorm(100)
hist(x, xlim=range(x), xlab= "Variable Label",
ylab="density", main="Title of plot", prob=TRUE, ps=30)
Run Code Online (Sandbox Code Playgroud)
该ps参数不会改变字体大小(但它在R帮助中?par表示它是"文本的点大小(但不是符号)").
还可以将字体大小从绘图功能中分离出来,例如hist?
为什么没有更多的开源易于使用Java的图表库?这个领域唯一成功的开源项目似乎是jfreechart,它甚至没有任何文档或示例可用.
我想绘制数据,然后创建一个新的数字和绘制数据2,最后回到原始绘图和绘图data3,有点像这样:
import numpy as np
import matplotlib as plt
x = arange(5)
y = np.exp(5)
plt.figure()
plt.plot(x, y)
z = np.sin(x)
plt.figure()
plt.plot(x, z)
w = np.cos(x)
plt.figure("""first figure""") # Here's the part I need
plt.plot(x, w)
Run Code Online (Sandbox Code Playgroud)
仅供参考我如何告诉matplotlib我已经完成了一个情节?做类似的事情,但并不完全!它不允许我访问原始情节.
如何在ggplot2中设置y轴和x轴的原点/截取?
x轴的线应该精确到y=Z.
有Z=0或另一个给定的价值.
我想补充LaTeX排版到地块元件R(例如:标题,轴标签,注释等)的使用任一组合base/lattice或与ggplot2.
问题:
LaTeX使用这些包进入图表,如果是这样,它是如何完成的? 例如,通过这里讨论的包进行Python matplotlib编译:http://www.scipy.org/Cookbook/Matplotlib/UsingTexLaTeXtext.usetex
是否有类似的过程可以生成这样的图R?
我想在R中叠加两个散点图,使得每组点具有其自己的(不同的)y轴(即,在图中的位置2和4),但是这些点看起来叠加在同一图上.
有可能这样做plot吗?
编辑显示问题的示例代码
# example code for SO question
y1 <- rnorm(10, 100, 20)
y2 <- rnorm(10, 1, 1)
x <- 1:10
# in this plot y2 is plotted on what is clearly an inappropriate scale
plot(y1 ~ x, ylim = c(-1, 150))
points(y2 ~ x, pch = 2)
Run Code Online (Sandbox Code Playgroud) 在R中,plot()函数采用pch控制图中点的外观的参数.我正在制作具有数万个点的散点图,并且更喜欢一个小的但不是太小的点.基本上,我觉得pch='.'太小了,但pch=19太胖了.有什么东西在中间或某种方式来缩小点以某种方式?
我试图在同一个图上绘制几个核密度估计,我希望它们都是不同的颜色.我有一个使用字符串的kludged解决方案,'rgbcmyk'并为每个单独的绘图单步执行,但我在7次迭代后开始重复.是否有更简单/更有效的方法来实现这一目标,并提供更多颜色选项?
for n=1:10
source(n).data=normrnd(rand()*100,abs(rand()*50),100,1); %generate random data
end
cstring='rgbcmyk'; % color string
figure
hold on
for n=1:length(source)
[f,x]=ksdensity(source(n).data); % calculate the distribution
plot(x,f,cstring(mod(n,7)+1)) % plot with a different color each time
end
Run Code Online (Sandbox Code Playgroud) 在过去的几天里,我一直在玩Numpy和matplotlib.我在尝试使matplotlib绘制函数而不阻塞执行时遇到问题.我知道在这里已经有很多线索提出了类似的问题,而且我已经搜索了很多但是没有设法让这项工作成功.
我曾经尝试过使用show(block = False),但我得到的只是一个冻结的窗口.如果我只是调用show(),则会正确绘制结果,但会阻止执行直到窗口关闭.从我读过的其他主题,我怀疑show(block = False)是否有效取决于后端.它是否正确?我的后端是Qt4Agg.你能看看我的代码并告诉我你是否看错了吗?这是我的代码.谢谢你的帮助.
from math import *
from matplotlib import pyplot as plt
print plt.get_backend()
def main():
x = range(-50, 51, 1)
for pow in range(1,5): # plot x^1, x^2, ..., x^4
y = [Xi**pow for Xi in x]
print y
plt.plot(x, y)
plt.draw()
#plt.show() #this plots correctly, but blocks execution.
plt.show(block=False) #this creates an empty frozen window.
_ = raw_input("Press [enter] to continue.")
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
PS.我忘了说我想在每次绘制内容时更新现有窗口,而不是创建一个新窗口.
我是R的新手,但是我已经制作了许多具有较小数据集的相关图.但是,当我尝试绘制一个大型数据集(2gb +)时,我可以很好地生成绘图,但图例不会显示.有什么建议?还是替代品?
library(gplots)
r.cor <- cor(r)
layout(matrix(c(1,1,1,1,1,1,1,1,2,2), 5, 2, byrow = TRUE))
par(oma=c(5,7,1,1))
cx <- rev(colorpanel(25,"yellow","black","blue"))
leg <- seq(min(r.cor,na.rm=T),max(r.cor,na.rm=T),length=10)
image(r.cor,main="Correlation plot Normal/Tumor data",axes=F,col=cx)
axis(1, at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]],
cex.axis=0.9,las=2)
axis(2,at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]],
cex.axis=0.9,las=2)
image(as.matrix(leg),col=cx,axes=T)
Run Code Online (Sandbox Code Playgroud)
错误
plot.new():图边距太大
tmp <- round(leg,2)
axis(1,at=seq(0,1,length=length(leg)), labels=tmp,cex.axis=1)
Run Code Online (Sandbox Code Playgroud)