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

Texts do not seem to respect viewport #387

Open
scottwittenburg opened this issue Feb 12, 2019 · 1 comment
Open

Texts do not seem to respect viewport #387

scottwittenburg opened this issue Feb 12, 2019 · 1 comment

Comments

@scottwittenburg
Copy link
Collaborator

The following script should result in a plot where the text labels, as well as the line segments, are cropped to be within the viewport.

import vcs

x = vcs.init(geometry=(600, 600))

vp = [0.25, 0.75, 0.1, 0.9]

xs = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
ys = [0.2, 0.4, 0.6, 0.5, 0.7, 0.3, 0.2, 0.1, 0.9, 0.4]
txt = [str(idx) for idx in range(len(xs))]

xmin = min(xs)
xmax = max(xs)
ymin = min(xs)
ymax = max(ys)

dx = 2

l = x.createline()
l.color = ['Green',]
l.viewport = vp
l.worldcoordinate = [xmin + dx, xmax - dx, ymin, ymax]
l.x = xs
l.y = ys

t = x.createtext()
t.viewport = vp
t.worldcoordinate = [xmin + dx, xmax - dx, ymin, ymax]
t.color = 'Red'
t.x = xs
t.y = ys
t.string = txt
t.height = 10

x.plot(l)
x.plot(t)

x.png('texts-viewport-issue.png')

However, the lines are cropped within the viewport but texts are not, as can be seen in this image:

texts-viewport-issue

I do not think this issue was introduced by the update to Context2D rendering in the VTK backend, because the thermo repo has an old baseline which shows that the problem has existed all along, but `vcs didn't have a test that caught it.

I have a fix in a branch on my fork, here. However, that branch illustrates that there is a problem with the templated viewport coordinates, as in projected plots, the viewport isn't big enough to allow room for the tick labels.

@scottwittenburg
Copy link
Collaborator Author

ping @danlipsa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant