Skip to content

fix static image generation to use --dpi#425

Merged
wdecoster merged 6 commits intowdecoster:masterfrom
microbemarsh:kaleido_update
Aug 29, 2025
Merged

fix static image generation to use --dpi#425
wdecoster merged 6 commits intowdecoster:masterfrom
microbemarsh:kaleido_update

Conversation

@microbemarsh
Copy link
Contributor

@microbemarsh microbemarsh commented Aug 24, 2025

This was a tricky one but I think it's finally there. Had to create the write_static_image function to export the images at the higher dpi than the default 72 that plotly uses. Minimal tests on a fastq.gz file output the high dpi static images and can be seen in the scripts/agm_tests folder of this branch.

I really hope this does the trick long-term but if there are issues with it please don't be afraid to @ me.

Should fix #424 but I recommend a quick test yourself @wdecoster before merging branches.

@microbemarsh microbemarsh marked this pull request as ready for review August 24, 2025 15:24
@wdecoster
Copy link
Owner

Much appreciated!

Could you limit the changes in nanoplot/NanoPlot.py to just what was necessary for the dpi? There are quite some imports that have changed back to the top. I moved them to other locations to make --version and --help much faster, and only import e.g. pandas and numpy when those are necessary for the code. Also the subdf = utils.subsample_datasets(datadf) if "start_time" in datadf else None shouldn't be removed. Maybe, in the future, it would be better to start a fresh branch for new fixes?

@microbemarsh
Copy link
Contributor Author

microbemarsh commented Aug 25, 2025

@wdecoster Sorry for the messy PR, I hope that this NanoPlot.py maintains the --help/--version speed better. I was hoping not to have to edit it and just stick to the plot.py but it looks like that wasn't possible to solve the resolution issue. Also, I'll delete this branch after it gets merged / or after you grab what you need for a new branch.

In Thanks,
Austin

@wdecoster wdecoster merged commit 5e7494a into wdecoster:master Aug 29, 2025
1 check passed
@wdecoster
Copy link
Owner

Thanks! I'll push this to pypi soon.

@wdecoster
Copy link
Owner

Each call to pio.get_chrome() takes about one minute? :-(
(At least, it does on my system...)

try:
    start_time = time.time()
    pio.get_chrome()
    time_taken = time.time() - start_time
    sys.stderr.write(f"Plotly successfully found Chrome in {time_taken:.2f} seconds.\n")

@microbemarsh
Copy link
Contributor Author

Wow it did not on my machine, I tested my files fastq.gz and produced all htmls and static files in around 20 seconds.

@wdecoster
Copy link
Owner

Hrm okay that would not be too bad indeed. In my case this is on WSL, would that explain the difference?

@microbemarsh
Copy link
Contributor Author

Honestly not sure, I was testing on two machines that both have very high speed internet but also saw in a quick google search can possibly be a first time thing? If you try it again is it still slow?

@wdecoster
Copy link
Owner

Hmm, every NanoPlot execution in the test was slow here. The first one was even 100 seconds. I must say that the whole static image generation from Plotly is a rather frustrating experience.

@microbemarsh
Copy link
Contributor Author

I absolutely agree, will certainly be on the lookout for alternatives in the near future.

@wdecoster
Copy link
Owner

I have been considering dropping it from NanoPlot entirely and just stick to HTML, but I don't know how many users would be terribly annoyed by that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plot resolution is low

2 participants