Matplotlib backend that avoids artifacts yet appropriate for web applications?

My chart has unwanted artifacts:

To troubleshoot I turned off the the 'agg' backend and they disappeared. Matplotlib used the default backend, I don’t know which one. I want to use a backend that doesn’t create artifacts yet is appropriate for web applications.
The documentation on backends states:

still others run web application servers to dynamically serve up
graphs

Based on the sparse documentation notes regarding that use case I believed agg was the only choice. I am building an application and know nothing about web development (yet). My question is which backend(s) are appropriate to not generate artifacts, and will be appropriate when I move to the web?

I could test the backends to see which ones don’t generate artifacts but I need SO wisdom for the latter part of the question.

Per a comments:

  • Upgraded to matplotlib 3.9.2
  • Upgraded to Pillow 10.4.0
  • Changed to .png format image

These two upgrades had no noticeable improvements to my problem while still using .jpeg format but saving the figure as a .png did. It may have been the combination of the updates and formatting.

Here’s the code to create the chart above:

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter, AutoMinorLocator
import numpy as np
from PIL import Image
mpl.use('agg')
plt.style.use('dark_background')
my_figure = plt.figure(**{'dpi': 100.0,
 'edgecolor': 'black',
 'facecolor': 'black',
 'figsize': (8.0, 6.0),
 'linewidth': 1.0})
my_figure.suptitle(**{'fontsize': 'x-large',
 'fontweight': 'semibold',
 'horizontalalignment': 'center',
 't': 'Binomial Distribution Pair Plot',
 'verticalalignment': 'top'})
my_figure.supxlabel(**{'fontsize': 'large',
 'fontweight': 'normal',
 'horizontalalignment': 'center',
 't': 'Failures',
 'verticalalignment': 'bottom'})
my_figure.supylabel(**{'fontsize': 'large',
 'fontweight': 'normal',
 'horizontalalignment': 'left',
 't': 'Probability',
 'verticalalignment': 'center'})
axes_dictionary = my_figure.subplot_mosaic(mosaic=[['binomial_w_cumulative_overlay']]
                    ,gridspec_kw={'wspace': 0.0, 'hspace': 0.0})
axes_dictionary['binomial_w_cumulative_overlay'].bar(**{'x': [0, 1, 2], 'height': [0.7778213593991469, 0.19641953520180488, 0.02380842850930969], 'label': 'individual probability', 'color': 'C0', 'zorder': 10})
axes_dictionary['binomial_w_cumulative_overlay'].bar(**{'x': [0, 1, 2], 'height': [0.7778213593991469, 0.9742408946009518, 0.9980493231102614], 'label': 'cumulative probability', 'color': 'C1', 'zorder': 5, 'alpha': 0.2})
axes_dictionary['binomial_w_cumulative_overlay'].set_xticks(ticks=[0, 1, 2], labels=[0, 1, 2])
axes_dictionary['binomial_w_cumulative_overlay'].set_ylim(ymax=1.0)
axes_dictionary['binomial_w_cumulative_overlay'].yaxis.set_minor_locator(AutoMinorLocator(2))
axes_dictionary['binomial_w_cumulative_overlay'].yaxis.set_major_formatter(PercentFormatter(xmax=1.0))
my_figure.savefig('test_figure.jpg')
Image.open('test_figure.jpg').show()
plt.show()

6

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật