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

Line width in plot #141

Open
mmagnuski opened this issue Jun 10, 2018 · 6 comments
Open

Line width in plot #141

mmagnuski opened this issue Jun 10, 2018 · 6 comments

Comments

@mmagnuski
Copy link

Is it possible to set line width when using ipyvolume.pylab.plot? The docs do not seem to mention this and I could not find any info on this anywhere else too. If it is not supported currently in plot - are there any hacky ways of achieving line width?

@maartenbreddels
Copy link
Collaborator

Hi Mikolaj,

It's basically not supported any more by WebGL (vs 1 at least):
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/lineWidth
If it works (windows and/or linux may actually sometimes support it, I remember seeing it having effect on linux), you can try this out (using master from github).

import ipyvolume as ipv
import numpy as np


x = np.linspace(0, 10, 100)
y = np.sin(x)
z = np.cos(x)

ipv.figure()
p = ipv.plot(x, y, z)
p.material.linewidth = 2
ipv.show()

Let me know if you get success!

cheers,

Maarten

@vidartf
Copy link
Contributor

vidartf commented Jun 11, 2018

@maartenbreddels three.js r91 added code in examples for fat lines via shaders, see mrdoob/three.js#11349. I'm considering exposing it in pythreejs given its usability.

@maartenbreddels
Copy link
Collaborator

Ah great, I saw some external libraries, but didn't know if I wanted to depend on that, if you plan to support it, I'll try to follow it.

@mmagnuski
Copy link
Author

Thanks @maartenbreddels! I will test it. The page you linked seems to indicate that Edge browser has full support for lineWidth? That is unexpected, but I will test it out.
I may encounter problems installing ipyvolume from git on Windows (had some problems previously with npm etc. and didn't solve that) so it may take some time. :)

@maartenbreddels
Copy link
Collaborator

On windows, I recomment using anaconda, and then install nodejs:
$ conda install -c conda-forge nodejs
Good luck!

@5aurabhpathak
Copy link

5aurabhpathak commented Aug 27, 2023

As of writing this, the current hack to adjust the linewidth is the following:

import ipyvolume as ipv
import numpy as np

num_pts = 1000
x = np.linspace(0, 10, num_pts)
y = np.sin(x)
z = np.cos(x)

ipv.figure()
p = ipv.plot(x, y, z)
p.material.visible = True  # this is required for the following to work 
p.size = 1.  # adjust this number for linewidth. can also be more or less than 1.
ipv.show()

This will draw the scatter points along the length of the line. The thickness of those can be adjusted. If there are a sufficient number of such points, this will give the illusion of linewidth. It will not work as well if the number of points is too few. One can experiment with num_pts to see the effect.

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

No branches or pull requests

4 participants