julia的几种画图方法

一、画图及可视化

方法一:

using Gadfly

using Cairo

julia> myplot =plot(x=rand(10),y=rand(10))

draw(PNG("myplot.png",4inch, 3inch), myplot)

 myplot = plot(..)

 # draw on every available backend

draw(SVG("myplot.svg", 4inch, 3inch), myplot)

draw(PNG("myplot.png", 4inch, 3inch), myplot)

draw(PDF("myplot.pdf", 4inch, 3inch), myplot)

draw(PS("myplot.ps", 4inch, 3inch), myplot)

draw(D3("myplot.js", 4inch, 3inch), myplot)

 方法二:使用Winston  问题:暂时没有发现能够画时间(datetime为横坐标的图!)

# 画二个点

julia> usingWinston

julia>display(plot(rand(1,100)))# 如果不用display可能有些情况不会显示图形

################################################

julia> plot(rand(1,100))

FramedPlot(...)

# 画二个点

julia>  figure1= FramedPlot();

point1 = Points(3, 3);

add(figure1, point1);

point2 = Points(2, 2);

add(figure1, point2);

Winston.display(figure1);

# 画一个曲线

x = linspace(0, 3pi, 100)

 c = cos(x)

 s = sin(x)

 p = FramedPlot(

        title="title!",

        xlabel="\\Sigma x^2_i",

        ylabel="\\Theta_i")

  add(p,FillBetween(x, c, x, s))

 add(p, Curve(x, c,color="red"))

 add(p, Curve(x, s,color="blue"))

 #####################################################

p = FramedPlot(

        aspect_ratio=1,

        xrange=(0,100),

        yrange=(0,100))

##############

 n = 21

 x = linspace(0,100, n)

 yA = 40 .+10randn(n)

 yB = x .+5randn(n)

 a = Points(x, yA,kind="circle")

 setattr(a,label="a points")

 b = Points(x, yB)

 setattr(b,label="b points")

 style(b,kind="filled circle")

 s = Slope(1,(0,0), kind="dotted")

 setattr(s,label="slope")

 l = Legend(.1, .9,{a,b,s})

 add(p, s, a, b, l)

################

x = linspace(pi, 3pi, 60)

 c = cos(x)

 s = sin(x)

  p =FramedPlot(aspect_ratio=1)

 setattr(p.frame1,draw_grid=true, tickdir=1)

  setattr(p.x1,label="bottom", subticks=1)

 setattr(p.y1,label="left", draw_spine=false)

 setattr(p.x2,label="top", range=(10,1000), log=true)

  setattr(p.y2,label="right", draw_ticks=false,

    ticklabels=["-1", "-1/2", "0","1/2", "1"])

 add(p, Curve(x, c,kind="dash"))

 add(p, Curve(x,s))

##

julia> x2 = rand(10,10)

10x10 Array{Float64,2}:

 0.564009  0.0189715 0.668941   …  0.990236   0.423469   0.594781

 0.588723  0.747681  0.515079      0.00496721  0.0813008 0.450878

 0.672323  0.469073  0.118781      0.0282153   0.208464  0.52431 

 0.159263  0.297813  0.828949      0.642512    0.915281  0.806548

 0.563958  0.281605  0.93284       0.168205    0.434135  0.927634

 0.724086  0.986885  0.96821    …  0.671119   0.86806    0.374594

 0.702004  0.153323  0.379379      0.479773    0.0251379 0.138291

 0.53355   0.232235  0.0172869     0.976708    0.429525  0.743494

 0.765813  0.243128  0.603948      0.271188    0.697181  0.0147205

 0.398034  0.677016  0.504992      0.350921    0.517337  0.352407

 julia> display(imagesc(x2))

 方法三:PyPlot.

因为studio 装不了,搞不清楚具体什么原因,就没有用这个画图了,但也是可以画的,据说,用起来还是比较方便的。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值