plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.29k stars 2.55k forks source link

remove `Loading [MathJax]/extensions/MathMenu.js` message #4341

Open zhimin-z opened 1 year ago

zhimin-z commented 1 year ago

I am working with plotly but the output image show the watermark: My code:

df = pd.read_json(os.path.join(path_rq12, 'macro-topics.json'))

categories = []
frequency_p = []
frequency_k = [] 

for index, group in df.groupby('Challenge_topic_macro'):
    categories.append(macro_topic_indexing[index])
    frequency_p.append(len(group[group['Challenge_type'] == 'problem']))
    frequency_k.append(len(group[group['Challenge_type'] == 'knowledge']))

# Create a stacked bar chart
fig = go.Figure(data=[
    go.Bar(name='Problem', x=categories, y=frequency_p, text=frequency_p, textposition='outside'),
    go.Bar(name='Knowledge', x=categories, y=frequency_k, text=frequency_k, textposition='outside')
])

# Change the bar mode
fig.update_layout(
    barmode='group',
    xaxis_title="Macro-topic Name",
    yaxis_title="Post Number",
    xaxis=dict(title_font=dict(size=18)), 
    yaxis=dict(title_font=dict(size=18)),
)
fig.show()
fig.write_image(os.path.join(path_rq12, 'Macro-topics frequency histogram.pdf'))

My output image: image

OS: Ubuntu 20.04 Python: 3.10.9 Plotly: 5.16.1

zhimin-z commented 1 year ago

Similar to https://github.com/plotly/plotly.py/issues/3469, any idea? @nicolaskruchten @chriddyp @jonmmease

Fratorhe commented 9 months ago

Do you have any updates on this?

Coding-with-Adam commented 9 months ago

Sorry but we don't have updates on this issue as of yet.

jav-ed commented 8 months ago

I see a similar issue when exporting to pdf. Nearly 2 years ago, the following worked for me:

  # -------------------------- first time -------------------------- #
  import plotly.express as px 
  import time 
  file_Name="some_Figure.pdf"
  fig_Throw_Away = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
  fig_Throw_Away.write_image(file_Name, format="pdf")
  time.sleep(0.1)

  # delete the dummy file again
  path_Cwd = Path.cwd()
  file_2_Del = path_Cwd/file_NamendError exceptions will be ignored (same behavior as the POSIX rm -f command).
  file_2_Del.unlink(missing_ok = True)

  # ------------------------ end first time ------------------------ #ndError exceptions will be ignored (same behavior as the POSIX rm -f command).
  file_2_Del.unlink(missing_ok = True)

  # ------------------------ end first time ------------------------ #

  # now run your actual code to generate the plot that you like

The idea is to create a dummy plot, wait a bit and after the waiting you can plot your actual figure that you like. Again, no guarantees, but it worked for me some time ago