Skip to content

Commit c6be8f9

Browse files
author
Stefan Heimersheim
authored
Fixed unintuitive fineness behaviour (#15)
Fixed the unintuitive fineness behaviour (issue #13) by removing the last contour level, such that contour levels for e.g. fineness=0.5 and contours [1,2] are now [0.5,1,1.5,2,2] instead of [0.5,1,1.5,2,2,2.5].
1 parent e49b034 commit c6be8f9

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fgivenx: Functional Posterior Plotter
33
=====================================
44
:fgivenx: Functional Posterior Plotter
55
:Author: Will Handley
6-
:Version: 2.3.0
6+
:Version: 2.4.0
77
:Homepage: https://github.com/williamjameshandley/fgivenx
88
:Documentation: http://fgivenx.readthedocs.io/
99

fgivenx/plot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def plot(x, y, z, ax=None, **kwargs):
3838
Thickness of contour lines. (Default: 0.3)
3939
4040
contour_color_levels: List[float], optional
41-
Contour color levels.
42-
(Default: `numpy.arange(0, contour_line_levels[-1] + 1, fineness)`)
41+
Contour color levels. (Default:
42+
`numpy.arange(0, contour_line_levels[-1] + fineness / 2, fineness)`)
4343
4444
fineness: float, optional
45-
Spacing of contour color levels. (Default: 0.1)
45+
Spacing of contour color levels. (Default: 0.5)
4646
4747
lines: bool, optional
4848
(Default: True)
@@ -69,7 +69,8 @@ def plot(x, y, z, ax=None, **kwargs):
6969
contour_line_levels = kwargs.pop('contour_line_levels', [1, 2, 3])
7070

7171
fineness = kwargs.pop('fineness', 0.5)
72-
default_color_levels = numpy.arange(0, contour_line_levels[-1] + 1,
72+
default_color_levels = numpy.arange(0,
73+
contour_line_levels[-1] + fineness / 2,
7374
fineness)
7475
contour_color_levels = kwargs.pop('contour_color_levels',
7576
default_color_levels)

fgivenx/test/test_plot.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def test_plot_transparent():
3131
cbar = plot(x, y, z, ax, alpha=0.7)
3232
assert type(cbar) is matplotlib.contour.QuadContourSet
3333

34+
def test_plot_fineness():
35+
x, y, z = gen_plot_data()
36+
37+
fig, ax = plt.subplots()
38+
cbar = plot(x, y, z, ax, fineness=0.1, contour_line_levels=[1,2,3,4])
39+
assert type(cbar) is matplotlib.contour.QuadContourSet
40+
assert len(cbar.levels) == 41
41+
3442

3543
def test_plot_wrong_argument():
3644
x, y, z = gen_plot_data()

planck.png

135 Bytes
Loading

plot.png

-1.66 KB
Loading

0 commit comments

Comments
 (0)