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

Bar plots don't support logy mode? #1233

Open
thoth291 opened this issue Mar 29, 2017 · 2 comments
Open

Bar plots don't support logy mode? #1233

thoth291 opened this issue Mar 29, 2017 · 2 comments
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Milestone

Comments

@thoth291
Copy link
Contributor

Here is the problem:
screen shot 2017-03-29 at 12 19 40 am

Here is the matplotlib code which works:

import matplotlib.pyplot as plt;
import numpy as np
import matplotlib.pyplot as plt

f=plt.figure(figsize=(12,4))
ax1 = plt.subplot(131)
ax1.bar(range(len(a['max'])),a['max'],alpha=0.5,align="edge",tick_label=a['test'])

ax2 = plt.subplot(132)
ax2.bar(range(len(a['max'])),np.exp(a['max']/10.0),alpha=0.5,align="center",tick_label=a['test'])

ax3 = plt.subplot(133)
plt.yscale('log')
ax3.bar(range(len(a['max'])),np.exp(a['max']/10.0),alpha=0.5,align="center",tick_label=a['test'])
#ax3.set_xticklabels(a['test']) # interestingly if I use this then ticks are not centered
f.savefig('test.png')

from IPython.display import Image
Image('test.png')

image

Is it me - or it's not possible?

P.S. More examples here

@philippjfr philippjfr added type: bug Something isn't correct or isn't working tag: backend: mpl labels Mar 29, 2017
@philippjfr
Copy link
Member

Added to the list of all the deficiencies of the BarPlot implementation, I'll try to see if there's a quick fix but if not this won't get fixed until we rewrite BarPlot from scratch.

@philippjfr philippjfr added this to the v1.11 milestone May 25, 2018
@philippjfr philippjfr modified the milestones: v1.11.0, v1.11.x Dec 4, 2018
@philippjfr philippjfr modified the milestones: v1.11.x, v1.12.0, v1.12.x Mar 22, 2019
@philippjfr philippjfr modified the milestones: v1.12.x, v1.13.0 Jan 5, 2020
@philippjfr philippjfr modified the milestones: v1.13.0, v1.13.x Mar 4, 2020
@philippjfr philippjfr modified the milestones: v1.14.x, v2.0 May 23, 2021
@TheoMathurin
Copy link
Contributor

TheoMathurin commented Jul 21, 2023

I'll give a partial update on the current state of the issue as of HoloViews 1.16.2, with bokeh backend.

Currently you will always get the warning "Logarithmic axis range encountered value less than or equal to zero, please supply explicit lower-bound to override default of 0.010" even if your data only include values > 0. Also the lower bound will be set to 0.01.

The issue lies with the fact that with a Bars element (and probably histogram), the low variable that is mentioned here is 0 whatever the data.

What's important here is that the bottom of the bars itself will be set at 0.01. And if you have a value lower than 0.01, the bar will go downward from 0.01:

data = [('one',8),('two', 10), ('three', 16), ('four', 8), ('five', 4), ('six', 1), ('seven', 1e-3)]
bars = hv.Bars(data, hv.Dimension('Car occupants'), 'Count').opts(logy=True)
bars

bokeh_plot(1)

It's a bit tricky to deal with bars on a logarithmic y-axis but I think that provided the element (here BarsPlot, which inherits its get_extents method from BarsMixin) returns the actual lower data from the data instead of 0, the issue will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: backend: mpl type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

3 participants