I've been running some optimization with optuna, and I'd like to produce plots with the same scale on both axes, but so far I was unable to find out how.
study = optuna.create_study(study_name=study_name,
storage=f"sqlite:///{results_folder}/{study_name}.db",
directions=["maximize", "maximize"],
load_if_exists=True)
# I tried either
fig_pareto = optuna.visualization.plot_pareto_front(study, target_names=['precision', 'recall'])
fig_pareto.show()
# or
fig, ax = plt.subplots()
optuna.visualization.matplotlib.plot_pareto_front(study, target_names=['precision', 'recall'])
ax.axis("equal")
ax.set_xlim(0.7, 1)
ax.set_ylim(0.7, 1)
target_names=['precision', 'recall'])
plt.savefig("some_name.png")
but without success. This is what the saved plot looks like:
With the first method, the pictures open in an interactive view in the browser and I can resize them, but there's no option to precisely make them square.
When using the second way, it looks like calling:
optuna.visualization.matplotlib.plot_pareto_front(study, target_names=['precision', 'recall'])
is not linking the produced plot to the ax object? If I do:
pareto_plot = optuna.visualization.matplotlib.plot_pareto_front(study, target_names=['precision', 'recall'])
the pareto_plot is an AxesSubplot object, can I manually load it in the axes?
Sorry, I had the answer right there. I had to do:
pareto = optuna.visualization.matplotlib.plot_pareto_front(study, target_names=['precision', 'recall'])
pareto.axis('equal')
plt.savefig("pareto_plot.png")