tight_bounds

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

tight_bounds

Jordan Ilott

I can't get a scatter plot that doesn't draw with tight bounds. I've tried setting the tight_bounds property on the range and range2d and also on the mapper. Can anybody offer some insight into this behavior?

Jordan


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: tight_bounds

John Wiggins
Can you post a minimal example that illustrates the problem? Normally, you should be able to do something like this:
plot_obj.index_mapper.range.tight_bounds = False
plot_obj.value_mapper.range.tight_bounds = False

-- John

On Feb 21, 2013, at 11:33 AM, Jordan Ilott wrote:

> I can't get a scatter plot that doesn't draw with tight bounds. I've tried setting the tight_bounds property on the range and range2d and also on the mapper. Can anybody offer some insight into this behavior?
>
> Jordan
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: tight_bounds

Jordan Ilott
I'm sorry for taking so long to reply. I've pasted an example below. I've just used scatter_inspector.py from the examples directory. On lines 35-42 I've tried to use the method suggested to disable the tight boundary. It doesn't matter if I apply the change to a plot object or to a renderer, there is no change in the output.

Thanks

Jordan




"""
Scattergram inspector tool

Allows the user to highlight and/or select individual points of a scattergram.

When the mouse hovers over a scatter point, it changes temporarily. If you click
on a point, you select and mark (or unselect and unmark) the point.
"""

# Major library imports
from numpy import random

# Enthought library imports
from enable.api import Component, ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import Item, Group, View

# Chaco imports
from chaco.api import ArrayPlotData, Plot, ScatterInspectorOverlay
from chaco.tools.api import PanTool, ZoomTool, ScatterInspector

#===============================================================================
# # Create the Chaco plot.
#===============================================================================
def _create_plot_component():

    # Create a random scattering of XY pairs
    x = random.uniform(0.0, 10.0, 50)
    y = random.uniform(0.0, 5.0, 50)
    pd = ArrayPlotData(x = x, y = y)
    plot = Plot(pd, border_visible=True, overlay_border=True)

    scatter = plot.plot(("x", "y"), type="scatter", color="lightblue")[0]

    #*******An attempt to turn off tight bounds.
    plot.index_mapper.range.tight_bounds = False
    plot.value_mapper.range.tight_bounds = False

    #Trying it with the renderer rather than the plot object makes no difference.
    #scatter.index_mapper.range.tight_bounds = False
    #scatter.value_mapper.range.tight_bounds = False
    #********
   
    # Tweak some of the plot properties
    plot.set(title="Scatter Inspector Demo", padding=50)

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    plot.overlays.append(ZoomTool(plot))

    # Attach the inspector and its overlay
    scatter.tools.append(ScatterInspector(scatter))
    overlay = ScatterInspectorOverlay(scatter,
                    hover_color="red",
                    hover_marker_size=6,
                    selection_marker_size=6,
                    selection_color="yellow",
                    selection_outline_color="purple",
                    selection_line_width=3)
    scatter.overlays.append(overlay)

    return plot

#===============================================================================
# Attributes to use for the plot view.
size=(900,500)
title="Tooltip demo"

#===============================================================================
# # Demo class that is used by the demo.py application.
#===============================================================================
class Demo(HasTraits):
    plot = Instance(Component)

    traits_view = View(
                    Group(
                        Item('plot', editor=ComponentEditor(size=size),
                             show_label=False),
                        orientation = "vertical"),
                    resizable=True, title=title
                    )

    def _plot_default(self):
         return _create_plot_component()

demo = Demo()

if __name__ == "__main__":
    demo.configure_traits()


On Thu, Feb 21, 2013 at 11:47 AM, John Wiggins <[hidden email]> wrote:
Can you post a minimal example that illustrates the problem? Normally, you should be able to do something like this:
plot_obj.index_mapper.range.tight_bounds = False
plot_obj.value_mapper.range.tight_bounds = False

-- John

On Feb 21, 2013, at 11:33 AM, Jordan Ilott wrote:

> I can't get a scatter plot that doesn't draw with tight bounds. I've tried setting the tight_bounds property on the range and range2d and also on the mapper. Can anybody offer some insight into this behavior?
>
> Jordan
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: tight_bounds

John Wiggins
Hi Jordan,

It works when I do this:
    plot = Plot(pd, border_visible=True, overlay_border=True)

    plot.index_mapper.range.tight_bounds = False
    plot.value_mapper.range.tight_bounds = False

    # Call plot() after setting tight_bounds = False
    scatter = plot.plot(("x", "y"), type="scatter", color="lightblue")[0]

    # Tweak some of the plot properties
    plot.set(title="Scatter Inspector Demo", padding=50)

You can also get the same effect by calling refresh() on the DataRange1D objects after setting tight_bounds:

    plot.index_mapper.range.refresh()
    plot.value_mapper.range.refresh()

HTH,
-- John


On Feb 24, 2013, at 2:56 PM, Jordan Ilott wrote:

> I'm sorry for taking so long to reply. I've pasted an example below. I've just used scatter_inspector.py from the examples directory. On lines 35-42 I've tried to use the method suggested to disable the tight boundary. It doesn't matter if I apply the change to a plot object or to a renderer, there is no change in the output.
>
> Thanks
>
> Jordan
>
>
>
>
> """
> Scattergram inspector tool
>
> Allows the user to highlight and/or select individual points of a scattergram.
>
> When the mouse hovers over a scatter point, it changes temporarily. If you click
> on a point, you select and mark (or unselect and unmark) the point.
> """
>
> # Major library imports
> from numpy import random
>
> # Enthought library imports
> from enable.api import Component, ComponentEditor
> from traits.api import HasTraits, Instance
> from traitsui.api import Item, Group, View
>
> # Chaco imports
> from chaco.api import ArrayPlotData, Plot, ScatterInspectorOverlay
> from chaco.tools.api import PanTool, ZoomTool, ScatterInspector
>
> #===============================================================================
> # # Create the Chaco plot.
> #===============================================================================
> def _create_plot_component():
>
>     # Create a random scattering of XY pairs
>     x = random.uniform(0.0, 10.0, 50)
>     y = random.uniform(0.0, 5.0, 50)
>     pd = ArrayPlotData(x = x, y = y)
>     plot = Plot(pd, border_visible=True, overlay_border=True)
>
>     scatter = plot.plot(("x", "y"), type="scatter", color="lightblue")[0]
>
>     #*******An attempt to turn off tight bounds.
>     plot.index_mapper.range.tight_bounds = False
>     plot.value_mapper.range.tight_bounds = False
>
>     #Trying it with the renderer rather than the plot object makes no difference.
>     #scatter.index_mapper.range.tight_bounds = False
>     #scatter.value_mapper.range.tight_bounds = False
>     #********
>    
>     # Tweak some of the plot properties
>     plot.set(title="Scatter Inspector Demo", padding=50)
>
>     # Attach some tools to the plot
>     plot.tools.append(PanTool(plot))
>     plot.overlays.append(ZoomTool(plot))
>
>     # Attach the inspector and its overlay
>     scatter.tools.append(ScatterInspector(scatter))
>     overlay = ScatterInspectorOverlay(scatter,
>                     hover_color="red",
>                     hover_marker_size=6,
>                     selection_marker_size=6,
>                     selection_color="yellow",
>                     selection_outline_color="purple",
>                     selection_line_width=3)
>     scatter.overlays.append(overlay)
>
>     return plot
>
> #===============================================================================
> # Attributes to use for the plot view.
> size=(900,500)
> title="Tooltip demo"
>
> #===============================================================================
> # # Demo class that is used by the demo.py application.
> #===============================================================================
> class Demo(HasTraits):
>     plot = Instance(Component)
>
>     traits_view = View(
>                     Group(
>                         Item('plot', editor=ComponentEditor(size=size),
>                              show_label=False),
>                         orientation = "vertical"),
>                     resizable=True, title=title
>                     )
>
>     def _plot_default(self):
>          return _create_plot_component()
>
> demo = Demo()
>
> if __name__ == "__main__":
>     demo.configure_traits()
>
>
> On Thu, Feb 21, 2013 at 11:47 AM, John Wiggins <[hidden email]> wrote:
> Can you post a minimal example that illustrates the problem? Normally, you should be able to do something like this:
> plot_obj.index_mapper.range.tight_bounds = False
> plot_obj.value_mapper.range.tight_bounds = False
>
> -- John
>
> On Feb 21, 2013, at 11:33 AM, Jordan Ilott wrote:
>
> > I can't get a scatter plot that doesn't draw with tight bounds. I've tried setting the tight_bounds property on the range and range2d and also on the mapper. Can anybody offer some insight into this behavior?
> >
> > Jordan
> >
> > _______________________________________________
> > Enthought-Dev mailing list
> > [hidden email]
> > https://mail.enthought.com/mailman/listinfo/enthought-dev
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev