-
Notifications
You must be signed in to change notification settings - Fork 112
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
Colorbar tick formatting #25
Conversation
Cool, thanks a lot for your effort. I have a comment on your code: I think we can simplify this even more. Consider importing only: from bokeh.models import TickFormatter then you can make the check like: def get_tick_formatter(formatter_arg):
if issubclass(type(formatter_arg), TickFormatter) :
return formatter_arg
elif isinstance(formatter_arg, str):
return NumeralTickFormatter(format=formatter_arg)
else:
raise ValueError("<colorbar_tick_format> parameter only accepts a string or a objects of bokeh.models.formatters.") Then this is a really small & nice integration of the feature. About tests, I haven't so far integrated all my tests for geoplots so far in the project. Could you write a 1 or 2 nice examples for the documentation (README.md), maybe one with the string and one with a formatter? Then, we could use these examples as test code for this feature! Cheers, Patrik |
ah, yeap, you are right-- Have also updated the documentation with the 2 examples of customising the colorbar tick labels. |
README.md
Outdated
|
||
If you want to display the numerical labels on your colorbar with an alternative to the scientific format, you | ||
can pass in a one of the [bokeh number string formats](https://bokeh.pydata.org/en/latest/_modules/bokeh/models/formatters.html#NumeralTickFormatter) | ||
or an instance of one of the [bokeh.modles.fomrmatters](bokeh.models.formatters) to the `colorbar_tick_format` argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bokeh.models.formatters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. Thanks for the extensive documentation also. If you correct my minor comments, also don’t forget to add your name to the CONTRIBUTORS.md file 👌🏼.
Cheers Patrik
category="Delta_Population_2017", | ||
simplify_shapes=5000, | ||
colormap="Inferno", | ||
colorbar_tick_format=PrintfTickFormatter(format="%4.2f")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice example 😉
pandas_bokeh/geoplot.py
Outdated
@@ -143,6 +147,17 @@ def convert_geoDataFrame_to_patches(gdf, geometry_column_name="geometry"): | |||
return gdf_new | |||
|
|||
|
|||
def get_tick_formatter(formatter_arg): | |||
|
|||
if isinstance(formatter_arg, TickFormatter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t this be issubclass here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but you can use:
issubclass(a.__class__, TickFormatter)
Just a matter of taste. I just think that with issubclass it is a bit clearer what happens here. Do whatever you like 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sure. Have changed it to issubclass.
Cool, this looks perfect for me. We should also add some tests, but we could do this in another pr if you want. Did you run the tests already? Otherwise I have to check it out and would then like to merge the branch 😉 |
Hmm, only
Yeah, that might be easier 😉 |
@wwymak : thanks again for helping me improve Pandas Bokeh. Do you plan to implement the tests yourself? The tests are very rudimentary at the moment and basically only check if the provided examples of the documentation run (better than nothing 😔). |
@PatrikHlobil I am happy to add tests, but I am not quite sure what's your testing policy? (as far as I can tell for geoplots you are mostly testing it doesn't throw an error when it plots ?) Or do you add visual tests as well? |
@wwymak: you are right, I basically check if the Generation an html Export of the plots break on changes. Therefore, I use at the moment just the examples of the README.md. For Geoplots, I just implemented 2 tests so far and I haven’t found time to implement the rest. There are no direct visual tests so far, but the tests create html files with the test plots under the Tests/plot folder. However, I do only check them before releasing a new version on PyPI. When I would start now with the problem, I would write it in a better testable way, but in the moment I am glad if the examples run and one can see obvious breaking changes. If you want and have the time, you could also implement the remaining Geoplots of the documentation in the tests 😊 |
wwymak [9:52 PM]
NumeralTickFormatter
bokeh.models.TickFormatter
, which gets passed as is to the colorbar options.@PatrikHlobil this works for the geoplot but I am not sure what your testing procedure is (and also what you would like me to do for the documentation?)