enthought / enthought/chaco

Right axis line not aligned with border

Open
#493 0 comments 0 reactions 0 assignees View on GitHub
ETS Backlog
Dominant language
Python
Stars
305
Forks
97
PR merge metrics
No merged PRs in 30d

Description

**Problem Description**

As reported by @chenqi0805 Right axes lines do not align with the right-hand border. For example:

![image](https://user-images.githubusercontent.com/600761/69408758-7bb6e900-0cff-11ea-90d9-221e90c6b823.png)

It is likely that the same would be seen with top axes.

**Reproduction Steps:**

```python
class PlotExample(HasTraits):
plot = Instance(Component)
traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False),
resizable=True, title="Tornado Plot",
width=800, height=600
)
def _plot_default(self):
(index_points, value_points) = self._get_points()
data = ArrayPlotData(x=index_points, y=value_points)
container = Plot(data)
plots = container.plot(('x', 'y'))
for plot in plots:
plot.padding = 60
container.add(plot)
bottom_axis = PlotAxis(plot, orientation='bottom')
label_list = ['var a', 'var b', 'var c', 'var d', 'var e', 'var f',
'var g', 'var h', 'var i']
vertical_axis = LabelAxis(plot, orientation='left',
title='Categories',
positions=list(range(1, 10)),
labels=label_list)
vertical2_axis = LabelAxis(plot, orientation='right',
positions=list(range(1, 10)),
labels=label_list)
container.x_axis.visible = False
container.y_axis.visible = False
container.underlays.append(vertical_axis)
container.underlays.append(vertical2_axis)
container.underlays.append(bottom_axis)
return container
def _get_points(self):
index = linspace(pi/4, 3*pi/2, 9)
data = sin(index) + 2
return (list(range(1, 10)), data)
```

**Expected behavior:**

The border and the axes should align.

I suspect that this is a mis-match between the calculation of the location of the right-hand axis location, here:

https://github.com/enthought/chaco/blob/cd191bc4ab3fb902c20b49dd604ad8d63cc31b3c/chaco/axis.py#L285-L287

compared to the computation of the bounds rectangle, here:

https://github.com/enthought/enable/blob/a88911fb525cfcfd5c52ca3c563aadf525832d3d/enable/component.py#L822-L824

Possibly with some half-pixel shifts thrown in for good measure.

The correct formula is likely:
```
self.x = self.component.x2 + 1.5*self.component.border_width - 1
```
Or something close to that.

**OS, Python version:** Shouldn't matter.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.