Hi, my name is M and I am looking for some help.
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 think it would be helpful for you to create an MWE as explained here Please read: make it easier to help you
i.e. something like:
p1 = plot(something) # I don't actually know how GeoMakie works
p2 = plot(something_else)
which reproduces your problem with some dummy data so that people can see for themselves what’s going on.
Would it also be allowed for me to make a github repo with my code and share that?
What happens if you save the fig explicitly?
I am also not sure, where the savefig function comes from because that I think is from the Plots.jl ecosystem.
I first save my histogram:
And then my Map:
I can also post my github project repo link if that would help, and I could show where exactly the problem occurs?
Oh funny that you should be here, I wrote you recently (a month or two back) about my project. I am using your YAXArrays package!
An MWE too long to fit in a comment is not M enough to W as an E.
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.
I solved the problem. Instead of using
I used what I found in a CairoMakie script
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
As you’ll see there, the MWE ended up being:
julia> using Markdown
┌ 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