I am trying to create a sunburst plot using Plotly. Everything is working fine except that after exporting that newly created SVG file into Overleaf and then creating PDF using LaTeX code, the image looks so weird. The texts are getting out of the image and overlapping with each other. Check the demo image here.
Here is the code I used to produce the image.
import pandas as pd
import plotly.express as px
import os
df = pd.read_excel('data/countries.xlsx')
df.head()
fig = px.sunburst(df, path=['Continent', 'Country'])
fig.show()
graphics_dir = "graphics"
if not os.path.exists(graphics_dir):
os.mkdir(graphics_dir)
fig.write_image(format='svg', file='{}/countries.svg'.format(graphics_dir))
I know how to fix this problem when I am generating graphics using Matplotlib from this link and it is working for me. But I do not know how to achieve this in Plotly.
I have managed to hack the whole process with advice from one of my colleagues. As I could not disable the font path from SVG, I have chosen another method. First, I converted the SVG file into PDF, and then I used the PDF instead of that SVG file. The benefit of converting SVG to PDF is that the font path of the SVG is no more available in the PDF. They become embedded into the PDF. This way, I have managed to fix the issue! Thanks.