我想將 wordcloud 匯出為 pdf 而不是 png,以便在放大時不會丟失質量。這是否可行,因為 wordcloud 本身已經是圖片?
這是我嘗試過的:
wc = WordCloud(max_font_size=120, max_words= 100, background_color="white", height=600,width=800)
wc = wc.generate_from_frequencies(mdict)
plt.imshow(wc, interpolation='bilinear')
plt.axis("off")
plt.show()
wc.to_file(outputpath "test.pdf")
但是它回傳一個帶有位圖格式圖片的pdf,就像一個png圖片。我想以真正的 pdf 格式(矢量格式)獲取圖片。
編輯:措辭
uj5u.com熱心網友回復:
本質上to_file你會得到 RGB 影像檔案(設定模式為有或沒有 alpha)但是to_svg從 1.7.0 版開始查看選項,然后你當然需要 svg 到 pdf!(使用瀏覽器輕松完成 pdf)
to_array() Convert to numpy array.
to_file(filename) Export to image file.
to_svg([embed_font, optimize_embedded_font, …]) Export to SVG.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/377321.html
