Change size of matplotlib fig

So I am using Mesa so create a simulation. In order to visualize it I am using the build in SolaraViz library to visualize the simulation. However I am facing a problem, the matplotlib graph that is being used to plot the simulation is too small. I've tried to scale the graph without success so far. The code used looks as following:
def agent_portrayal(agent):

if (isinstance(agent, Car)):
return {
"color": "red",
"marker": "8", # hexagon
"size": 50,
}

def post_process(ax):
ax.set_aspect("equal")
ax.set_xticks([])
ax.set_yticks([])
ax.set_facecolor("gray")

SpaceGraph = make_space_component(
agent_portrayal, post_process=post_process, draw_grid=False
)
page = SolaraViz(
model1,
components=[SpaceGraph],
model_params=model_params,
name="Car Simulation",
)
page
def agent_portrayal(agent):

if (isinstance(agent, Car)):
return {
"color": "red",
"marker": "8", # hexagon
"size": 50,
}

def post_process(ax):
ax.set_aspect("equal")
ax.set_xticks([])
ax.set_yticks([])
ax.set_facecolor("gray")

SpaceGraph = make_space_component(
agent_portrayal, post_process=post_process, draw_grid=False
)
page = SolaraViz(
model1,
components=[SpaceGraph],
model_params=model_params,
name="Car Simulation",
)
page
This creates the following dashboard (see included image) All I want is to make the matplotlib part (the part with the gray background and red hexagons) larger. Any help would be appriciated!
No description
5 Replies
MaartenBreddels
Hi! can you create a reporducible example at https://py.cafe ? That saves us a lot of time to reproduce what you have
PyCafe: Create & Share Streamlit, Dash and Python Apps Online.
Playground for Python web frameworks. Run and edit Python code snippets for web frameworks in a web browser.
Mighty_Pig
Mighty_PigOP3w ago
For sure, once I am back at my pc I'll create a example
MaartenBreddels
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (4, 2)
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (4, 2)
This affects the image.. but making it larger does not make the figure size larger. I think you have to ask the mesa team for this.
Mighty_Pig
Mighty_PigOP2w ago
Mmmh thanks! So I just tried it and it seems it is what we wanted! Thanks again!
Want results from more Discord servers?
Add your server