using PyPlot
plot([i for i = 1:20],[i^2 for i = 1:20])
And my Apple computer (Mojave, 2017) will log me out and close all my windows. Is there a crowd favorite plotting alternative that I could use as a temporary alternative in Julia?
I’m seeing the same issue on both 1.1 and 1.2. This wasn’t a problem for me just a week ago. The only thing I can think of that I changed in the interim was updating macOS (a point update from 10.14.[4 or 5] to 10.14.6). I tried updating to Julia 1.2 but that didn’t fix the issue. If I plot within vscode rather than from a terminal REPL then it works fine. Pulling up figure windows from pyplot in python also works fine.
I think It is the backend - one needs to change it. I’m afraid I don’t remember what i changed it to. (A mac specific one I think) I can look it up when I’m back at a desktop.
I should add that this also happens with pure python. The backend 'backend': 'TkAgg' leads to this crash. I just double-checked and confirmed this. In Python, I switch to the MacOSX backend,
import matplotlib.pyplot as plt
plt.switch_backend('MacOSX')
after which matplotlib plotting works fine without any issues.
EDIT: following the Readme at PyPlot.jl, the following works from Julia:
using PyCall
pygui(:qt5)
using PyPlot
x = range(0,1,length=100);
y = cos.(x);
plot(x,y)
But for practical purposes probably best to fix this in the matplotlibrc file : in ~/.matplotlib/matplotlibrc just add the following line:
As a result, back in April 2019 I changed PyPlot to not use tkagg by default anymore on MacOS (don't default to tk on macos (closes #410) · JuliaPy/PyPlot.jl@6bd7b68 · GitHub). So the only reason this would show up anymore is if you are explicitly requesting tkagg (either in your .matplotlibrc file or via the MPLBACKEND environment variable).
It is not necessary to change your .matplotlibrc file unless you were explicitly setting the backend to tkagg, which is not common.
It is possible but I don’t remember ever setting this to tkagg - I had assumed that the fresh anaconda install modified this setting. What I know for certain is that before the anaconda install PyPlot worked fine on my system.