Skip to content

Setting limits containing zero in pub_plot #112

@chuaxr

Description

@chuaxr

I am getting unexpected behavior from limits containing zero when using pub_plot:

Here's an example trying to plot a sample file (created by cdo -f nc4 -topo,r24x12 topo.nc) with version 1.1.6.

python -c 'import nctoolkit;nctoolkit.open_data("topo.nc").pub_plot(var="topo",out="test0.png",mid_point=1,limits=[0,2])' gives a plot that does not have limits at [0,2].

test0

python -c 'import nctoolkit;nctoolkit.open_data("topo.nc").pub_plot(var="topo",out="test1.png",mid_point=1,limits=[-2,2])' also does not have limits at [-2,2].

test1

However,
python -c 'import nctoolkit;nctoolkit.open_data("topo.nc").pub_plot(var="topo",out="test2.png",mid_point=0,limits=[-2,2])' behaves as expected.

test2

My guess is that moving lines 464-466 in static_plot.py out of the try loop would help, and that mid_point=0 happens to work because of lines 530-533.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions