Why my plot looks weired and different from others'?

I used the code from Quantecon to create a plot. It looks weird with thick lines and its background. I guess the issue is with my computer because both Jupyter notebook and Juno gave the same result.

Hi @DShiu,

Would you please post the code you used to create the graph? There are lots of examples and several different plotting libraries so we need a bit more information to be able to help.

1 Like

using InstantiateFromURL
github_project("QuantEcon/quantecon-notebooks-julia", version = "0.5.0")
# uncomment to force package installation
# github_project("QuantEcon/quantecon-notebooks-julia", version="0.5.0", instantiate=true)
using LinearAlgebra, Statistics
using Distributions, Expectations, NLsolve, Roots, Random, Plots, Parameters
gr(fmt = :png);;

n = 50
dist = BetaBinomial(n, 200, 100) # probability distribution
@show support(dist)
w = range(10.0, 60.0, length = n+1) # linearly space wages

using StatsPlots
plt = plot(w, pdf.(dist, support(dist)), xlabel = "wages", ylabel = "probabilities", legend = false)

This example looks like it might be pretty old and I’m having trouble running it. What version of Julia are you using?

Nvm, it ran. I’m getting this result:

What environment are you running in? I’m using Atom w/ Juno, and the above is snipped from a screenshot. [EDIT: you said Juno and Jupyter. How about Julia and OS versions?]

Your plot looks good to me. My was from Julia 1.3.1 and Windows 10. I got the same weired plot on both Juno and Jupyter.

I don’t know what’s causing that difference.

Hi DShiu, I got a similar problem which is similar to yours.

I have trace my problem to Plots

And to solve my problem I did this

Pin Plots to version 0.29.9

[91a5bcdd] Plots v0.29.9 ⚲

I think there is some issue which cause Plots to jump back to version 0.27.X something to do with dependecies

PS: I think the problem is cause by some new version of StatsPlots

I had to reset StatsPlots to an older version below
add StatsPlots@0.14.1

I think this is the problem with StatsPlots that is causing the problem with Plots going back to 0.27.x

I am not an expert on Julia packages so my explanation may be wrong.
But this is what I think happened.
StatsPlots went from 0.14.1 to a newer version
This cause Plots to go from 0.29.9 to 0.27.x
This cause your graphs to look weird.

This is unlikely to be the reason as (1) StatsPlots is compatible with the current Plots version (which is 1.2.5 btw, not 0.29) and (2) the look of the standard Plots hasn’t changed for a long time, and they never (to my knowledge) looked like the above.

What’s the output of ]st for your environment, @DShiu? Also, what does a plot look like if you just do

julia> using Plots

julia> plot(rand(10))

?

1 Like

…and what’s your backend()? To me it looks like there might be some configuration loaded in the background (matplotlib can be configured via ~/.matplotlib/matplotlibrc, maybe also GR?).

EDIT: I don’t use Plots.jl anymore so not sure how the backend is set implicitly…

1 Like

Below are the output I got:

(quantecon-notebooks-julia) pkg> st
Project quantecon-notebooks-julia v0.5.0
Status D:\Dropbox\Research\Project.toml
[2169fc97] AlgebraicMultigrid v0.2.2
[28f2ccd6] ApproxFun v0.11.5
[7d9fca2a] Arpack v0.3.1
[aae01518] BandedMatrices v0.10.1
[6e4b80f9] BenchmarkTools v0.4.3
[a134a8b2] BlackBoxOptim v0.5.0
[ffab5731] BlockBandedMatrices v0.4.6
[324d7699] CategoricalArrays v0.7.1
[34da2185] Compat v2.1.0
[a93c6f00] DataFrames v0.19.4
[1313f7d8] DataFramesMeta v0.5.0
[5721bf48] DataVoyager v0.3.1
[39dd38d3] Dierckx v0.4.1
[9fdde737] DiffEqOperators v3.5.0
[31c24e10] Distributions v0.21.3
[2fe49d83] Expectations v1.1.1
[a1e7a1ef] Expokit v0.2.0
[d4d017d3] ExponentialUtilities v1.5.1
[442a2c76] FastGaussQuadrature v0.4.0
[1a297f60] FillArrays v0.6.4
[9d5cd8c9] FixedEffectModels v0.8.5 ⚲
[c8885935] FixedEffects v0.3.0 ⚲
[587475ba] Flux v0.9.0
[f6369f11] ForwardDiff v0.10.3
[38e38edf] GLM v1.3.1 ⚲
[28b8d3ca] GR v0.41.0
[40713840] IncompleteLU v0.1.1
[43edad99] InstantiateFromURL v0.4.0
[a98d9a8b] Interpolations v0.12.2
[b6b21f68] Ipopt v0.6.0
[42fd0dbc] IterativeSolvers v0.8.1
[4076af6c] JuMP v0.20.0
[5ab0869b] KernelDensity v0.5.1
[ba0b0d4f] Krylov v0.3.0
[0b1a1467] KrylovKit v0.4.0
[b964fa9f] LaTeXStrings v1.0.3
[5078a376] LazyArrays v0.10.0
[0fc2ff8b] LeastSquaresOptim v0.7.4
[093fc24a] LightGraphs v1.3.0
[7a12625a] LinearMaps v2.5.2
[5c8ed15e] LinearOperators v0.5.4
[76087f3c] NLopt v0.5.1
[2774e3e8] NLsolve v4.0.0
[429524aa] Optim v0.19.3
[1dea7af3] OrdinaryDiffEq v5.3.0
[d96e819e] Parameters v0.12.0
[14b8a8f1] PkgTemplates v0.6.3
[91a5bcdd] Plots v0.27.0
[f27b6e38] Polynomials v0.5.2
[af69fa37] Preconditioners v0.3.0
[92933f4c] ProgressMeter v1.1.0
[1fd47b50] QuadGK v2.1.0
[fcd29c91] QuantEcon v0.16.1
[1a8c2f83] Query v0.12.2
[ce6b1742] RDatasets v0.6.3
[d519eb52] RegressionTables v0.2.2 ⚲
[295af30f] Revise v2.2.0
[f2b01f46] Roots v0.8.3
[df8f2f22] SASLib v1.2.0
[47a9eef4] SparseDiffTools v0.8.0
[684fba80] SparsityDetection v0.1.1
[90137ffa] StaticArrays v0.11.0
[2913bbd2] StatsBase v0.32.0
[3eaba693] StatsModels v0.6.5
[f3b207a7] StatsPlots v0.12.0
[88034a9c] StringDistances v0.6.4
[112f6efa] VegaLite v0.7.0
[e88e6eb3] Zygote v0.3.4
[37e2e46d] LinearAlgebra
[9a3f8284] Random
[2f01184e] SparseArrays
[10745b16] Statistics
[8dfed614] Test

Plots.GRBackend()

Okay so your Plots and GR version are out of date, and you could try ]up’ing, although I see that you’ve got quite a few packages pinned to certain versions so they might restrict you from upgrading.

Still this makes it harder to debug, so can you just make a new environment, add only Plots to it and then try a simple plot again?

1 Like

I restarted Juno and made the plot. It looks normal now. So I guess the issue is from QuantEcon.

1 Like

Perhaps QuantEcon sets undesirable defaults http://docs.juliaplots.org/latest/generated/gr/#gr-ref42