在朱莉娅中保存情节图

发布于 2025-02-07 16:55:13 字数 1036 浏览 1 评论 0原文

我是朱莉娅(Julia)的新手,正在使用图。jl[gr]库来创建图。我试图将我的情节保存为PNG,以显示在我的GTK GUI上。我可以使用savefig函数(

​ 的: https://stackoverflow.com/a/62981826/13306172

遵循这篇文章是

ERROR: MethodError: no method matching savefig(::Plots.Plot{Plots.GRBackend}, ::String)
 x = 1:10; y = rand(10, 4)
import GR
using Plots
using PlotlyBase
using PlotlySave
gr()
import PlotlySave.savefig

function return_image_plot()
        x = 1:10; y = rand(10, 4) 
        x1 = 1:10; y1 = rand(10, 1) 
        plot1  = Plots.plot(x, y)
        plot2  = Plots.plot(x1, y1)
        plotty = Plots.plot(plot1, plot2, layout = (2, 1))
        
        Plots.savefig(plotty, "ploty2.png")
end

不成功 我还尝试使用我还尝试使用PlotySave Julia库 https://github.com/github.com/hhaensel/plotlysave。 jl 但没有成功,还收到了我遵循/复制多个SOF帖子的“无匹配方法”错误

,但仍未成功。任何帮助都将受到赞赏。

I am new to Julia and am using the Plots.jl [GR] library to create plots. I am trying to save my plot as a PNG to display on my GTK GUI. I am able to save the plot as an html file and text file but not .png using the savefig function (https://docs.juliaplots.org/latest/api/#Plots.savefig-Tuple{Plots.Plot,%20AbstractString})

I have been unsuccessful following this post: https://stackoverflow.com/a/62981826/13306172

The error i receive is:

ERROR: MethodError: no method matching savefig(::Plots.Plot{Plots.GRBackend}, ::String)
 x = 1:10; y = rand(10, 4)
import GR
using Plots
using PlotlyBase
using PlotlySave
gr()
import PlotlySave.savefig

function return_image_plot()
        x = 1:10; y = rand(10, 4) 
        x1 = 1:10; y1 = rand(10, 1) 
        plot1  = Plots.plot(x, y)
        plot2  = Plots.plot(x1, y1)
        plotty = Plots.plot(plot1, plot2, layout = (2, 1))
        
        Plots.savefig(plotty, "ploty2.png")
end

I also attempted to use I also attempted to use PlotySave Julia library https://github.com/hhaensel/PlotlySave.jl but was unsuccessful and also received a 'no matching method' error

I have followed/copied multiple SoF posts but have continued to be unsuccessful. Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦境 2025-02-14 16:55:13

尝试以下操作:

using Plots

function saveplot()
    x = 1:10
    y1 = rand(10, 4)
    y2 = rand(10, 1)
    p1 = plot(x, y1)
    p2 = plot(x, y2)
    p = plot(p1, p2, layout=(2, 1))
    
    savefig(p, "plot.png")
end

saveplot()

Try this:

using Plots

function saveplot()
    x = 1:10
    y1 = rand(10, 4)
    y2 = rand(10, 1)
    p1 = plot(x, y1)
    p2 = plot(x, y2)
    p = plot(p1, p2, layout=(2, 1))
    
    savefig(p, "plot.png")
end

saveplot()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文