Skip to content

Commit

Permalink
Avoid trimming plots to always make them equal size.
Browse files Browse the repository at this point in the history
This is very useful, if you want to compare different plots or animate the whole process.

Fixes #79
  • Loading branch information
kiudee committed Aug 25, 2020
1 parent 979fe8d commit c593b4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
History
=======

0.6.0-beta.2 (2020-08-25)
-------------------------
* Fix plots being of varying sizes dependent on their labels and ticks.
This should make it easier to animate them.

0.6.0-beta.1 (2020-08-24)
-------------------------
* Improve default parameters to be slightly more robust for most use cases and
Expand Down
2 changes: 0 additions & 2 deletions tune/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ def local( # noqa: C901
full_plotpath = plotpath / f"{timestr}-{iteration}.png"
plt.savefig(
full_plotpath,
pad_inches=0.1,
dpi=300,
bbox_inches="tight",
facecolor="#36393f",
)
root_logger.info(f"Saving a plot to {full_plotpath}.")
Expand Down
13 changes: 11 additions & 2 deletions tune/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def plot_objective(
dimensions=None,
n_random_restarts=100,
alpha=0.25,
margin=0.65,
colors=None,
fig=None,
ax=None,
Expand Down Expand Up @@ -200,8 +201,10 @@ def plot_objective(
if also `None` to `['X_0', 'X_1', ..]`.
* `n_random_restarts` [int, default=100]
Number of restarts to try to find the global optimum.
* `alpha` [float, default=0.5]
* `alpha` [float, default=0.25]
Transparency of the sampled points.
* `margin` [float, default=0.65]
Margin in inches around the plot.
* `colors` [list of tuples, default=None]
Colors to use for the optima.
* `fig` [Matplotlib figure, default=None]
Expand Down Expand Up @@ -234,9 +237,15 @@ def plot_objective(
space.n_dims,
figsize=(size * space.n_dims, size * space.n_dims),
)
width, height = fig.get_size_inches()

fig.subplots_adjust(
left=0.05, right=0.95, bottom=0.05, top=0.95, hspace=0.1, wspace=0.1
left=margin / width,
right=1 - margin / width,
bottom=margin / height,
top=1 - margin / height,
hspace=0.1,
wspace=0.1,
)
failures = 0
while True:
Expand Down

0 comments on commit c593b4b

Please sign in to comment.