Changing the background color in a graphics tool
I am going to use a python package named graph-tool to render graphs. For some reason, it sets the background to gray every time, keeping the graph looking far from pleasing. Does anyone know how to change it to white?
For example, this example code:
from graph_tool.all import *
g = price_network(5000)
p = sfdp_layout(g)
graph_draw(g, pos=p, output="example.png")
runs on an iPython laptop, displays a graph with a white background on the screen, but the saved image has a gray background.
The result is the same as the format used for the output (at least with .png, .pdf and .svg). There was no such problem with networkX, but graphical drawing is slower and much less flexible.
Thanks for any help!
source to share
The "gray background" you see is your PNG viewer for rendering a transparent background. For example, I see a checkerboard pattern on my screen:
but when i load the image or print it wherever there is (default) white background:
Flatten the image in the editor to remove the alpha channel if that worries you.
In theory, you should go gprops={"bgcolor":"white"}
up to graph_draw , but that doesn't work for me.
source to share