mirror of
https://github.com/clearml/clearml
synced 2025-06-12 01:21:37 +00:00
Fix axis range settings when logging plots
This commit is contained in:
parent
ca3b3af005
commit
265dbe4a8c
@ -470,9 +470,10 @@ class PatchedMatplotlib:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# let plotly deal with the range in realtime (otherwise there is no real way to change it to
|
# let plotly deal with the range in realtime (otherwise there is no real way to change it to
|
||||||
plotly_renderer.plotly_fig.get('layout', {}).get('xaxis', {}).pop('range', None)
|
if not plotly_renderer.plotly_fig.get("layout", {}).get("xaxis", {}).pop("custom_range", False):
|
||||||
plotly_renderer.plotly_fig.get('layout', {}).get('yaxis', {}).pop('range', None)
|
plotly_renderer.plotly_fig.get("layout", {}).get("xaxis", {}).pop("range", None)
|
||||||
|
if not plotly_renderer.plotly_fig.get("layout", {}).get("yaxis", {}).pop("custom_range", False):
|
||||||
|
plotly_renderer.plotly_fig.get("layout", {}).get("yaxis", {}).pop("range", None)
|
||||||
return deepcopy(plotly_renderer.plotly_fig)
|
return deepcopy(plotly_renderer.plotly_fig)
|
||||||
|
|
||||||
plotly_dict = our_mpl_to_plotly(mpl_fig)
|
plotly_dict = our_mpl_to_plotly(mpl_fig)
|
||||||
|
@ -485,6 +485,12 @@ def prep_ticks(ax, index, ax_type, props):
|
|||||||
axis_dict["tick0"] = tick0
|
axis_dict["tick0"] = tick0
|
||||||
axis_dict["dtick"] = dtick
|
axis_dict["dtick"] = dtick
|
||||||
axis_dict["tickmode"] = None
|
axis_dict["tickmode"] = None
|
||||||
|
if ax_type == "x" and "xlim" in props:
|
||||||
|
axis_dict["range"] = [props["xlim"][0], props["xlim"][1]]
|
||||||
|
axis_dict["custom_range"] = True
|
||||||
|
elif ax_type == "y" and "ylim" in props:
|
||||||
|
axis_dict["range"] = [props["ylim"][0], props["ylim"][1]]
|
||||||
|
axis_dict["custom_range"] = True
|
||||||
elif scale == "log":
|
elif scale == "log":
|
||||||
try:
|
try:
|
||||||
axis_dict["tick0"] = props["axes"][index]["tickvalues"][0]
|
axis_dict["tick0"] = props["axes"][index]["tickvalues"][0]
|
||||||
@ -497,16 +503,18 @@ def prep_ticks(ax, index, ax_type, props):
|
|||||||
axis_dict = dict(nticks=props["axes"][index]["nticks"])
|
axis_dict = dict(nticks=props["axes"][index]["nticks"])
|
||||||
base = axis.get_transform().base
|
base = axis.get_transform().base
|
||||||
if base == 10:
|
if base == 10:
|
||||||
if ax_type == "x":
|
if ax_type == "x" and "xlim" in props:
|
||||||
axis_dict["range"] = [
|
axis_dict["range"] = [
|
||||||
math.log10(props["xlim"][0]),
|
math.log10(props["xlim"][0]),
|
||||||
math.log10(props["xlim"][1]),
|
math.log10(props["xlim"][1]),
|
||||||
]
|
]
|
||||||
elif ax_type == "y":
|
axis_dict["custom_range"] = True
|
||||||
|
elif ax_type == "y" and "ylim" in props:
|
||||||
axis_dict["range"] = [
|
axis_dict["range"] = [
|
||||||
math.log10(props["ylim"][0]),
|
math.log10(props["ylim"][0]),
|
||||||
math.log10(props["ylim"][1]),
|
math.log10(props["ylim"][1]),
|
||||||
]
|
]
|
||||||
|
axis_dict["custom_range"] = True
|
||||||
else:
|
else:
|
||||||
axis_dict = dict(range=None, type="linear")
|
axis_dict = dict(range=None, type="linear")
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
|
Loading…
Reference in New Issue
Block a user