Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unintuitive fineness behaviour #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fgivenx: Functional Posterior Plotter
=====================================
:fgivenx: Functional Posterior Plotter
:Author: Will Handley
:Version: 2.3.0
:Version: 2.4.0
:Homepage: https://github.com/williamjameshandley/fgivenx
:Documentation: http://fgivenx.readthedocs.io/

Expand Down
9 changes: 5 additions & 4 deletions fgivenx/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def plot(x, y, z, ax=None, **kwargs):
Thickness of contour lines. (Default: 0.3)

contour_color_levels: List[float], optional
Contour color levels.
(Default: `numpy.arange(0, contour_line_levels[-1] + 1, fineness)`)
Contour color levels. (Default:
`numpy.arange(0, contour_line_levels[-1] + fineness / 2, fineness)`)

fineness: float, optional
Spacing of contour color levels. (Default: 0.1)
Spacing of contour color levels. (Default: 0.5)

lines: bool, optional
(Default: True)
Expand All @@ -69,7 +69,8 @@ def plot(x, y, z, ax=None, **kwargs):
contour_line_levels = kwargs.pop('contour_line_levels', [1, 2, 3])

fineness = kwargs.pop('fineness', 0.5)
default_color_levels = numpy.arange(0, contour_line_levels[-1] + 1,
default_color_levels = numpy.arange(0,
contour_line_levels[-1] + fineness / 2,
fineness)
contour_color_levels = kwargs.pop('contour_color_levels',
default_color_levels)
Expand Down
8 changes: 8 additions & 0 deletions fgivenx/test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_plot_transparent():
cbar = plot(x, y, z, ax, alpha=0.7)
assert type(cbar) is matplotlib.contour.QuadContourSet

def test_plot_fineness():
x, y, z = gen_plot_data()

fig, ax = plt.subplots()
cbar = plot(x, y, z, ax, fineness=0.1, contour_line_levels=[1,2,3,4])
assert type(cbar) is matplotlib.contour.QuadContourSet
assert len(cbar.levels) == 41


def test_plot_wrong_argument():
x, y, z = gen_plot_data()
Expand Down
Binary file modified planck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.