I try to plot a gyroid surface in sage which is defined implicitly. However, I get reflections of the light source on my surface which do not look very good. How can I change light settings for the 3d plots?
I tried to set different texture properties for my surface, but the changes showed no result. I also tried to set the light source but also without any resulting changes.
x, y, z = var('x,y,z')
def phi_g(x,y,z):
X=x+pi/2
Y=y+pi/2
Z=z+pi/2
return sin(X)*cos(Y)+sin(Y)*cos(Z)+sin(Z)*cos(X)
G1=implicit_plot3d(phi_g(x,y,z)==0.02, (x,0,2*pi), (y,0,2*pi), (z,0,2*pi),color='blue', frame=False, plot_points=80)
G2=implicit_plot3d(phi_g(x,y,z)==-0.02, (x,0,2*pi), (y,0,2*pi), (z,0,2*pi),color='red', frame=False, plot_points=80)
C=cube(center=(pi, pi, pi), size=2*pi, color='grey', opacity=0.1)
G=G1+G2+C
plot_G=G.plot()
plot_G.save('g.png',figsize=20,zoom=1.27)
I would like to have the output without any reflections of the light source on the surface.
I don't really use it much, but I think the Tachyon ray-tracer in Sage can do a lot of what you are looking for. I don't know if the implicit_plot3d fully supports these things in the default viewer.
Related
I create a simple plot using GLMakie:
GLMakie.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )
The result looks like this:
Looks like the x-axis is heavily quantized. The Plots package handles the same command just fine:
Plots.scatter( range((-3e-9+1e-3)..(3e-9+1e-3),100), range(1..100,100) )
GLMakie can also handle the same plot if the x range is centered on 0:
GLMakie.scatter( range((-5e-9)..(5e-9),100), range(1..100,100) )
Why is this happening? Does GLMakie use a smaller float for speed? Can I do anything to avoid this?
Does GLMakie use a smaller float for speed?
Yes it does. OpenGL commonly uses 32 bit floats and Makie has been built with Float32 as a result. Right now you'd have normalize your data and adjust ticks manually to fix this. See https://makie.juliaplots.org/stable/examples/layoutables/axis/index.html#modifying_ticks
There are also a bunch of issues regarding this on github, for example https://github.com/JuliaPlots/Makie.jl/issues/1373.
I have the following dataframe:
df <- data.frame(x=c(1,3,-3,-2), y=c(2,5,2,1),z=c(1,7,4,1))
I use the following rgl code:
library(rgl)
open3d()
plot3d(df,col=3,type="p", radius=0.5)
plot3d(df,col=rgb(1,0,0.3),alpha=0.5, add=T,type="s",radius=1)
and get the following:
Now, I like my figure, but would like to reduce the gloss/shininess (or even eliminate it completely). It takes up too much of my plotting character. How do I do that?
I tried passing shininess as a parameter, and while it somewhat helps, it does not get rid of it completely. Even with shininess 128 (maximum value),it does not get rid of it completely.
library(rgl)
open3d()
plot3d(df,col=3,type="p", radius=0.5)
plot3d(df,col=rgb(1,0,0.3),alpha=.3, add=T,type="s",radius=1, shininess=128)
Then I get:
Can I get rid of the shinyness completely, or at least in a manner that it is almost nonexistent?
If you set the specular material colour to black, you won't see any shininess. A more extreme version is to set lit to FALSE. For example, here the spheres are drawn with specular = "black":
The black dots are the points you drew. And here they are drawn with lit = FALSE:
This removes important cues that people use for depth perception, so I don't recommend it.
Edited to add: One other thing I recommend if you're drawing transparent spheres: add back = "cull". Otherwise you can get weird interactions between the front and back faces of the spheres in certain rotations.
I'm trying to graph some data in an iTorch notebook. I can generate plots fine, but I want to change the endpoints of the axes. (My autogenerated y-axis is from 20-100, but I'd rather it be from 0-100 since it's a graph of percentages and I want the lower left corner to be the origin.)
I looked in the documentation, and in the list of methods implemented, and in the source code, but didn't find anything that lets me do this. I can zoom the generated graph, but it preserves aspect ratio, so I can't zoom just one of the axes.
Does anyone know how to do this? I'm half convinced this isn't implemented, but it seems like a very strange feature to leave out.
You can change the axis scale by mouse-scrolling over the axis ticks, and translate by drag-and-drop.
I know it's not ideal, but I had the same problem and that's the best I could find so far.
I'm trying to generate a 3d scatterplot using rgl. It looks great on my screen, but whenever I export it as a PDF (or any other postscript format) it completely ignores any size specifications I use.
(I'm running RGui v.2.15.1 and rgl v.0.92.892 on a Macbook under Mountain Lion.)
For example:
library(rgl)
set.seed(1982)
points3d(runif(5),runif(5),runif(5), size=20)
# points look huge
rgl.postscript('testplot.pdf', fmt='pdf')
# points look tiny
Does anyone have an idea for a way to get this to work? The resolution of the images I get using rgl.snapshot don't look so good, and I would really like to get a vector image for this plot.
Also, I followed this thread and I got text to resize just fine, but not points. So I thought one way to work around this would be to plot my points as text using a circle as my character, but I couldn't get rgl to accept symbols or expressions either...
Confirmed on Windows, look like some paper size scaling problem. You might try
spheres3d(runif(5),runif(5),runif(5),radius=0.1)
as a workaround if you can live with real 3d.
I'm trying to make a visualization that looks like this http://www.gradient-da.com/img/temperature%20surface%20plot%20470x406.JPG http://www.gradient-da.com/img/temperature%20surface%20plot%20470x406.JPG.
The idea is to have a 3D surface plot overlapping a 2d representation of a surface.
I can build arbitrary surfaces/polygon shapes (as in http://addictedtor.free.fr/graphiques/graphcode.php?graph=135 ) and I can make the respective 2D plot. What I don't seem to be able to figure out is the way to put them together in a nice way (like the one shown in the jpg above).
I've tried googling for the answer, but I wasn't able to find anything similar done in R.
Any help would be greatly appreciated!
EDIT: The 2D portion is not a projection of the 2D one. I chose this specific picture to illustrate this. For example
Here the 2D portion is the image of the circuit and on the 3D portion is the temperature).
In 2D you can have the map of a city and in 3D the traffic
etc...
Best,
Bruno
I will give a theoretical Idea,
In the same 3D plot, select a plane perpendicular to the 3D surface (just below the 3D-surface) and project all the values to it. Instead of 2D & 3D plot, you will use only a 3D plot, which also plots your surface.
HTH
It looks like the 2D plot is a layout of a microelectronic circuit, albeit with some detail skipped, and the 3D plot is perhaps a thermal plot of the same circuit.
I don't know enough about R's capabilities, but I imagine it would be easier to generate the two plots separately with R from the same dataset which represents the layout information (but with and without the thermal data) and then combine them with a graphics manipulation program.
No help in R, but you can do something similar in ROOT as seen in this image:
taken from the THistPainter class documentation.
The code is open source and could be examined if wanted for reimplementation.
Maybe you should try to make an opengl texture out of your 2d picture and map it on a 3d polygon to be included in your scenegraph?
Don't really understand if you wish to do it with R specifically, so maybe diving in opengl is a too low level for you. In case you'd be ready for that, you may reuse a simple java library that simplify plotting 3d surface: http://code.google.com/p/jzy3d
Hope that helps,
Martin
What you're looking for is called a texture map -- and if it's not provided in the R graphics package, you may be able to do it "by hand". The suggestion below may not be fast or convenient (or even helpful, as I'm not really familiar with R), but it may actually work...
Since you know you can draw a 3D surface plot with specified colors, you can try drawing a flat 3D surface using the colors of your image.
If R also lacks methods for extracting its data from image formats, there is an image format called PPM (standing for Portable PixMap), one variant of which is basically space-separated decimal numbers. After converting your image to this format (using Photoshop, say, or some dedicated image conversion program), it should be relatively easy to input into R.