Skip to content

'MPLBACKEND=webagg' is overwritten by agg when $DISPLAY is not set on Linux #14903

Closed
@GreenCourt

Description

@GreenCourt

Bug report

  • The environment variable MPLBACKEND=webagg is overwritten by 'agg' when $DISPLAY is not set on Linux.
  • The behavior of backend:webagg written in matplotlibrc was as same as MPLBACKEND=webagg (I tried).
  • I want to avoid hard-coding the backend to .py file, because I use the same code on other environment.

Code for reproduction

# matplotlibrc
webagg.open_in_browser : False
webagg.address : 0.0.0.0
# test.py
import matplotlib.pyplot as plt
print(plt.get_backend())

Actual outcome

When I type the shell command MPLBACKEND=WebAgg DISPLAY= python test.py,

agg

the backend is overwritten by agg.

When I type the shell command MPLBACKEND=WebAgg DISPLAY=:0 python test.py (although X11 is not installed),

WebAgg

I can use webagg.

Expected outcome

When I type the shell command MPLBACKEND=WebAgg DISPLAY= python test.py,

WebAgg
  • I want to use webagg even when X11 is not installed.
  • I want to use the environment variable MPLBACKEND to avoid hard-coding the backend.

Question

Does matplotlib overwrite the backend by 'agg', when $DISPLAY is empty?
I understand that the fallback behavior is useful.
However, is there any reason that webagg must be fallbacked to agg?

Or, is there a correct way (not setting the $DISPLAY) to avoid the fallback behavior?

Matplotlib version

  • Operating system: Debian 10
  • Matplotlib version: 3.1.0
  • Python version: 3.7.3 (anaconda)

Metadata

Metadata

Assignees

Labels

Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.status: confirmed bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions