Plots vs. PyPlot seems to have changed…
In the past, the following worked (Julia 1.1.0):
using Plots
pyplot()
This doesn’t work any more – if I do this, I get a lengthy error message:
┌ Warning: Error requiring PyPlot from Plots:
│ LoadError: MethodError: no method matching getproperty(::PyCall.PyObject, ::String)
│ Closest candidates are:
│ getproperty(::Any, !Matched::Symbol) at sysimg.jl:18
│ Stacktrace:
│ [1] top-level scope at none:0
│ [2] include at .\boot.jl:326 [inlined]
│ [3] include_relative(::Module, ::String) at .\loading.jl:1038
│ [4] include at .\sysimg.jl:29 [inlined]
│ [5] include(::String) at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\Plots.jl:1
│ [6] top-level scope at none:0
│ [7] eval at .\boot.jl:328 [inlined]
│ [8] eval at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\Plots.jl:1 [inlined]
│ [9] (::getfield(Plots, Symbol("##294#321")))() at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:67
│ [10] err(::getfield(Plots, Symbol("##294#321")), ::Module, ::String) at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:38
│ [11] #293 at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:66 [inlined]
│ [12] withpath(::getfield(Plots, Symbol("##293#320")), ::String) at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:28
│ [13] (::getfield(Plots, Symbol("##292#319")))() at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:65
│ [14] #invokelatest#1 at .\essentials.jl:742 [inlined]
│ [15] invokelatest at .\essentials.jl:741 [inlined]
│ [16] #3 at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:19 [inlined]
│ [17] iterate at .\generator.jl:47 [inlined]
│ [18] _collect(::Array{Function,1}, ::Base.Generator{Array{Function,1},getfield(Requires, Symbol("##3#4"))}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .\array.jl:619
│ [19] map at .\array.jl:548 [inlined]
│ [20] loadpkg(::Base.PkgId) at C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:19
│ [21] #invokelatest#1 at .\essentials.jl:742 [inlined]
│ [22] invokelatest at .\essentials.jl:741 [inlined]
│ [23] require(::Base.PkgId) at .\loading.jl:861
│ [24] require(::Module, ::Symbol) at .\loading.jl:853
│ [25] top-level scope at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends.jl:486
│ [26] eval at .\boot.jl:328 [inlined]
│ [27] _initialize_backend(::Plots.PyPlotBackend) at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends.jl:485
│ [28] backend(::Plots.PyPlotBackend) at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends.jl:182
│ [29] #pyplot#253 at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends.jl:33 [inlined]
│ [30] pyplot() at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends.jl:33
│ [31] top-level scope at In[1]:2
│ [32] eval at .\boot.jl:328 [inlined]
│ [33] softscope_include_string(::Module, ::String, ::String) at C:\Users\my-user-name\.julia\packages\SoftGlobalScope\cSbw5\src\SoftGlobalScope.jl:218
│ [34] execute_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\my-user-name\.julia\packages\IJulia\gI2uA\src\execute_request.jl:67
│ [35] #invokelatest#1 at .\essentials.jl:742 [inlined]
│ [36] invokelatest at .\essentials.jl:741 [inlined]
│ [37] eventloop(::ZMQ.Socket) at C:\Users\my-user-name\.julia\packages\IJulia\gI2uA\src\eventloop.jl:8
│ [38] (::getfield(IJulia, Symbol("##15#18")))() at .\task.jl:259
│ in expression starting at C:\Users\my-user-name\.julia\packages\Plots\47Tik\src\backends\pyplot.jl:24
└ @ Requires C:\Users\my-user-name\.julia\packages\Requires\9Jse8\src\require.jl:40
I have updated PyPlot
.
If I forget about pyplot()
and default to gr()
(i.e., don’t specify the backend), then I avoid the error messages. However, gr()
produces substandard plots for my use – (i) gr
doesn’t have complete support for LaTeX, and (ii) it sometimes does something strange wrt. scaling: here is what I try to do…
using Plots
using LaTeXStrings
# function
f(x,u) = -exp(-1/u)*x^2 + 0.1*exp(-2/u)*x
x = range(0,5,length=25)
u=range(0.01,0.1,length=25)
f3d = plot(u,x,f,st=:surface,c=:blues,colorbar=:none)
plot!(f3d,xlabel=L"u", ylabel=L"c_A",zlabel=L"dc_A/dt")
#plot!(f3d,xlabel=L"u", ylabel=L"c_\mathrm{A}",zlabel=L"\frac{d c_\mathrm{A}}{dt}")
fc =plot(u,x,f,st=:contour,c=:blues)
plot!(fc,xlabel=L"u", ylabel=L"c_A")
#plot!(fc,xlabel=L"u", ylabel=L"c_\mathrm{A}")
plot(f3d,fc,layout=(2,1))
I’ve had to comment out things that give error messages with gr()
– but that should work with pyplot()
. Even without error messages, gr()
(i) does not add labels to f3d
, and (ii) messes up the scaling of f3d
:
Any ideas on how to fix this? Have I done anything wrong?