Project Context: I am working on environmental analysis using Julia and DataCubes. Coding Problem: My code works. Everything is good. Except for saving my figures. First I create a histogram, which I then save as a figure. Next, I create a figure using GeoMakie and the figure is displayed correctly when the display(fig) command is executed, however when I attempt to save the figure with savefig(“Images/FileName2”), the file being saved is the previous figure, although the name is correct.
Is it possible that I am not clearing the “canvas” where the figures are being plotted? How can one do this? I apologize for the basic noob questions, but I have spent 8 hours on this and looking in the internet and chatgpt have not yielded me the hoped for results.
Thanks so much in advanced for your time and patience.
I mean (almost) everything’s allowed, we’re not the posting police, but by my estimation you’re 374% more likely to get quick help if you provide people with a small (in this case I guess it can be <10 lines of code) example that they can run on their own machines to investigate.
Take a look at @nilshg 's example for structure. It should be something I can copy-paste into my REPL and have it work. You can make some toy data with rand() - the plots don’t have to be your real plots.
savefig(“FileName.png”)
I used what I found in a CairoMakie script
save(“FileName.png”, fig)
You all have good points. If it’s worth your time and of interest, I can explain my situation.
I am not a skilled programmer and I have limited experience with debugging. It is a new skill that I need to practice.
As I am new to this all, I do not yet know the “codex of coders” if you will. In the future, I will try to make a MWE. In this case, I do not understand all of the code well enough to create a MWE for my specific example from scratch.
Thank you everybody for commenting and providing input, I appreciate your time.
Glad you got it to work. I would really encourage you to put some effort into the whole MWE thing when asking for help - not just because providing an MWE means you’re much more likely to get help quickly, but also because it teaches you good problem-solving habits when coding.
The process of really trying to narrow things down, thinking through which parts of a larger codebase you need to run to produce a certain error from scratch, will very often make you see the issue more clearly. Many times when I find myself in these situations I find the solution to my problem when trying to narrow it down to an MWE, as it makes me think harder about what exactly is going wrong and where.
As an example, yesterday I ran some old Pluto notebooks for the first time on the recently released Julia 1.10 alpha, and was faced with some pretty inscrutable errors about “parser failure, falling back to flisp” which didn’t mean anything to me. In trying to cut down the notebook enough to reproduce the error minimally, I found this issue which I filed as a bug with JuliaSyntax:
As you’ll see there, the MWE ended up being:
julia> using Markdown
julia> md"$)"
┌ Error: JuliaSyntax parser failed — falling back to flisp!
so I managed to go down from a >1,000 LOC notebook to six characters!
I see, I see. That’s really a good point. Thanks for taking your time to share the process and providing an example of it at work. I will keep this in mind for future struggles