Before everything starts, if you have installed the Plots package before and reported an error, it is recommended to C:\用户\用户名\.julia\packages
delete all Plots and GR in it, or simply uninstall julia and then directly .julia
delete the folder and the folder where julia is installed, and install julia again To ensure a pure installation environment, because the residual files will interfere with subsequent package compilation (really a cheating design).
The first step is to install Plots.
] #进入Pkg REPL模式
add Plots
Under normal circumstances, it will be completed smoothly, but there may be a problem that libGR.dll cannot be found when plots are actually used. GR must be installed manually at this time. The following content refers to the answer to this feedback .
First enter it add GR
. After the installation (the speed is slower), open C:\用户\用户名\.julia\packages\GR
the deps folder, there should be a gr folder in it, and the path is as follows. If not, create a gr folder yourself.
Then go to GR official website to download the full package, I downloaded the file name gr-0.34.1-Windows-x86_64.tar.gz
, size is 68.6MB. After decompressing with PeaZip twice, you get three folders bin, fonts, include, directly copy and paste these three folders to the gr folder to overwrite the files with the same name. Then go back to Pkg REPL and enter build GR
. Return to the julia REPL, enter it using GR
, and wait for it to be precompiled before you can use GR. Enter the histogram(randn(10000))
test effect.
Finally, enter it using Plots
and wait for it to complete precompilation, and you can use Plots. Enter the x=[1,2];y=[1,2];plot(x,y)
test effect. However, I found that there are still problems when outputting animations because ffmpeg is not installed. You have to install it manually. First go to the official website to download the appropriate build, as shown in the figure:
After decompression, a bunch of files are obtained:
Create a new ffmpeg folder in the previous deps directory, and copy all the above files into it. Next, create a new ffmpeg folder on the D drive, that is D:\ffmpeg
, copy those files into it again and D:\ffmpeg\bin
add it to 环境变量-用户变量-path
it. You can enter in cmd to ffmpeg
check whether the addition is successful. Reopen julia to create the animation correctly.
Plots gives three examples on Github. The first is the Lorenz attractor, as follows:
(By the way, the output animation in Atom can be viewed by clicking the output directory link in the REPL.)
The second is wave. Some additional packages need to be installed, as follows:
]
add PyCall
build PyCall
add ProgressMeter
add LaTexStrings
And add it in front of the sample code using Plots
.
The third is the iris dataset. The additional installation is as follows:
]
add RDatasets
add StatPlots
add DataFrames
add Query
And add it before the sample code using DataFrames
.
Postscript: If you have any questions, you can search on Github's project issue, or find it on CSDN. Looking at other people's blogs , there seems to be a simpler solution to the first problem, which I haven't verified.