moshi4 / pyCirclize

Circular visualization in Python (Circos Plot, Chord Diagram, Radar Chart)
https://moshi4.github.io/pyCirclize/
MIT License
715 stars 42 forks source link

Massive size on save to svg - vectors of sector borders and some other lines have tons of nodes #56

Closed dnjst closed 6 months ago

dnjst commented 7 months ago

example01-inkscape-nodes

Hello! I would like to save pycirclize plots to svg to submit for publication in vector format (required for the journal).

I found that upon saving to svg, the output files are massive and unwieldy in any editor. The .svg is >1 MB.

Opening the .svg file in inkscape, I found that the black borders around the sector are being rendered as hundreds of tiny points, rather than as a continuous curve in the vector.

Is there any way the code can be adjusted so that it can save to vector in a more efficient way? Arrows and links seem to work fine, it is just those border boxes so far as I can tell.

To reproduce, you can use the Example 1. Circos Plot and change the save command to:

circos.savefig("example01.svg")

This also occurs in phylogenetic trees, where the lines consist of more nodes than should be necessary (although I am unsure about how vector rendering works):

example04

Thank you so much for this program which renders really compelling images.

moshi4 commented 7 months ago

Hi @dnjst,

I did not notice the large SVG file size because I did not check the SVG output results of pyCirclize very often. The problem was caused by too many points to represent a curve with a particular vector object.

In the newly released pyCirclize v1.3.0, the number of points to represent a curve has been reduced to one-tenth, resulting in a smaller output SVG file size. I am not sure if it will be small enough for you, but it will certainly be smaller than before.