Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH: Optional 3d bar shading #7691

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

Merged
merged 2 commits into from
Mar 22, 2017

Conversation

phobson
Copy link
Member

@phobson phobson commented Dec 27, 2016

Closes #7683

@codecov-io
Copy link

codecov-io commented Dec 27, 2016

Current coverage is 62.11% (diff: 100%)

Merging #7691 into master will increase coverage by <.01%

@@             master      #7691   diff @@
==========================================
  Files           174        174          
  Lines         56022      56024     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          34799      34801     +2   
  Misses        21223      21223          
  Partials          0          0          

Powered by Codecov. Last update 159f36e...a99c034

@phobson phobson self-assigned this Dec 28, 2016
@phobson phobson force-pushed the optional-3d-bar-shading branch from 907bb0b to 67d1642 Compare December 29, 2016 02:09
# fake data
_x = np.arange(4)
_y = np.arange(5)
_xx, _xx = np.meshgrid(_x, _y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here, should be _xx, _yy = ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

bottom = np.zeros_like(top)
width = depth = 1

ax1.bar3d(x, y, bottom, width, depth, top, shade=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify to ax1.bar() instead of ax1.bar3d()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this one. I'm trying to draw 3-dimensional bars. I thought bar would draw 2-D bars on the 3D Axes object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, sorry, my reply apparently never got sent. For Axes3D objects, ax.bar() is the alias of ax.bar3d(). The bar3d() is an anachronism, much like set_xlim3d().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it all back. I could have sworn we separated the flat bar stuff out. You are right.

ax2.bar3d(x, y, bottom, width, depth, top, shade=False)
ax2.set_title('Not Shaded')

fig.canvas.draw()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be plt.show()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"""Generate a 3D barplot.

This method creates three dimensional barplot where the width,
depth, height, and color of the bars can all ne uniquely set.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "ne" --> "be"

zsort : str, optional
The z-axis sorting scheme passed onto
:func:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
shape : bool, optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: 'shape' --> 'shade'

x2d, y2d = x2d.ravel(), y2d.ravel()
z = x2d + y2d
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z, shade=True)
fig.canvas.draw()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the unneeded draw()

remove_text=True,
extensions=['png']
)
def test_bar3d_dflt_actually3d():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer test names and baseline image names that are the same or very nearly the same. It makes it easy to match a bad image file with the test in the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough. I'll change them.

remove_text=True,
extensions=['png']
)
def test_bar3d_dflt_actually3d_no_shade ():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraneous space between function name and parens.

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.arange(4)
y = np.arange(5)
x2d, y2d = np.meshgrid(x, y)
x2d, y2d = x2d.ravel(), y2d.ravel()
z = x2d + y2d
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z)
ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z, shade=False)
fig.canvas.draw()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go ahead and take it out here, too

@@ -20,16 +20,37 @@ def test_bar3d():
ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)


@cleanup
def test_bar3d_dflt_smoke():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh... I wonder why this was a smoke test?

@phobson phobson force-pushed the optional-3d-bar-shading branch from 67d1642 to a99c034 Compare January 2, 2017 00:27
@phobson phobson changed the title WIP: Optional 3d bar shading ENH: Optional 3d bar shading Jan 2, 2017
@WeatherGod
Copy link
Member

WeatherGod commented Jan 2, 2017 via email

@phobson
Copy link
Member Author

phobson commented Jan 2, 2017

@WeatherGod Oh, I see. Should I deprecated bar3d then?

@phobson
Copy link
Member Author

phobson commented Jan 2, 2017

Wait, I take it back, I'll still confused.

In axes3d.py, I see:

    def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
        '''
        Add 2D bar(s).
        ...
        '''

And then:

    def bar3d(self, x, y, z, dx, dy, dz, color=None,
              zsort='average', shade=True, *args, **kwargs):
        """Generate a 3D barplot.
        ...
        """

These seem like two very different and current methods. In the example that I created I wanted to demonstrate the difference that using shading makes, so 3D bars need to be generated in both cases.

The plot looks like this:

plot_3d_bars copy

Perhaps this would be clarified if the example was renamed to plot_bars3d

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

The coordinates of the anchor point of the bars.

dx, dy, dz : scalar or array-like
The width, depth, and height of the bars, resprectively.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: respectively.

zsort : str, optional
The z-axis sorting scheme passed onto
:func:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
shade : bool, optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the default?

@NelleV NelleV changed the title ENH: Optional 3d bar shading [MRG+1] ENH: Optional 3d bar shading Jan 13, 2017
@NelleV
Copy link
Member

NelleV commented Jan 13, 2017

Thanks for the example and the docstring update. It looks great!

@NelleV
Copy link
Member

NelleV commented Jan 16, 2017

I hadn't seen the previous comments. I can have a look at it if you'd like

@QuLogic
Copy link
Member

QuLogic commented Feb 24, 2017

Any chance you will get back to this soon @phobson?

@phobson
Copy link
Member Author

phobson commented Feb 24, 2017

@QuLogic happy to rebase, but I'm still unclear what @WeatherGod meant with his comments.

@phobson phobson force-pushed the optional-3d-bar-shading branch from a99c034 to 43bb1c1 Compare February 27, 2017 20:20
@phobson
Copy link
Member Author

phobson commented Feb 27, 2017

@QuLogic rebased and squashed everything.
@WeatherGod could you take a second look at this. I'm still not sure what meant by this

Despite the name of the example, ax.bar puts 2D bars in a 3D space while ax.bar3d draws actual prisms

@WeatherGod
Copy link
Member

We still have the other things I have noticed to fix, though.

@phobson
Copy link
Member Author

phobson commented Feb 27, 2017

@WeatherGod understood. I'm looking for clarity on what they might be.

@phobson phobson force-pushed the optional-3d-bar-shading branch from bb4834c to fac8a25 Compare February 27, 2017 21:15
@phobson
Copy link
Member Author

phobson commented Feb 27, 2017

@WeatherGod oops, sorry. I didn't see your other inline comments 🐑

I took care of them and force-pushed

@phobson phobson force-pushed the optional-3d-bar-shading branch from fac8a25 to 333e444 Compare February 27, 2017 21:18
Copy link
Member

@WeatherGod WeatherGod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost there... just noticed a couple more typos and 1 code question.

:func:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
shape : bool, optional (default = True)
When true, the dark sides of the bars (relative to the
plot's source of light), shaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: shape --> shade

Also, the description is missing a verb. Additionally, I think there is supposed to be a blank line between the zsort entry and the shade entry?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing a verb for this sentence, and possibly a blank line between the zsort entry and the shade entry.

@@ -2511,9 +2536,13 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
facecolors = list(mcolors.to_rgba_array(color))
if len(facecolors) < len(x):
facecolors *= (6 * len(x))
normals = self._generate_normals(polys)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this here? wouldn't it make a lot more sense if it was in the if shade block?

@phobson phobson force-pushed the optional-3d-bar-shading branch from 13639c1 to 448e5d7 Compare February 28, 2017 18:05
@WeatherGod
Copy link
Member

Ah, I almost completely forgot... we need a "what's new" entry for this.

@NelleV
Copy link
Member

NelleV commented Mar 19, 2017

@phobson Do you think you'll have time to write this what's new entry?

--------------------------------------------

A new ``shade`` parameter has been added the 3D bar plotting method.
The default behavior remains to the shade the bars, but now users
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "to shade the bars"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gahhh i read that like 5 times. i'll fix :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(shakes fist at self)

closes matplotlib#7683

Also expands the testing and documentation of bar3d
@phobson phobson force-pushed the optional-3d-bar-shading branch from 397198d to a218cb1 Compare March 20, 2017 18:09

A new ``shade`` parameter has been added the 3D bar plotting method.
The default behavior remains to shade the bars, but now users
have to the option of setting ``shade`` to ``False``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraneous "to"

@phobson phobson force-pushed the optional-3d-bar-shading branch from a218cb1 to 8e535e6 Compare March 21, 2017 15:46
@phobson
Copy link
Member Author

phobson commented Mar 22, 2017

ping @WeatherGod

@WeatherGod WeatherGod merged commit ee61ee4 into matplotlib:master Mar 22, 2017
@phobson phobson deleted the optional-3d-bar-shading branch March 22, 2017 21:21
@QuLogic QuLogic changed the title [MRG+1] ENH: Optional 3d bar shading ENH: Optional 3d bar shading Mar 23, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Mar 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.