Open slowkow opened 1 year ago
This issue from the python package nglview
looks related to mine. Is there a similar way we can rotate the view in R?
At the moment this is not possible but I will have a look if I can implements this.
Thank you, Niels!
I pushed an update to github that adds setScale
, setRotation
, and setPosition
functions for controlling scale, rotation, and position of representations.
Let me know if this works for you.
library(NGLVieweR)
my_sele <- "9:A"
NGLVieweR("2bvp") %>%
stageParameters(backgroundColor = "white", zoomSpeed = 1) %>%
addRepresentation(
type = "cartoon"
) %>%
addRepresentation(
type = "ball+stick",
param = list(
sele = my_sele
)
) %>%
addRepresentation(
type = "label",
param = list(
sele = my_sele,
labelType = "format",
labelFormat = "[%(resname)s]%(resno)s", # or enter custom text
labelGrouping = "residue", # or "atom" (eg. sele = "20:A.CB")
color = "black",
fontFamiliy = "sans-serif",
xOffset = 1,
yOffset = 0,
zOffset = 0,
fixedSize = TRUE,
radiusType = 1,
radiusSize = 1, # Label size
showBackground = TRUE
# backgroundColor="black",
# backgroundOpacity=0.5
)
) %>%
setRotation(190,0,200) %>%
setPosition(5,5,0) %>%
setScale(1.5)
Thank you! After installing from github, your example works.
But I didn't notice any difference after deleting this line: setPosition(5,5,0)
Ah yes sorry. I just put it for demonstration purposes. It allows you to move the whole structure in the x, y, z position. The numbers are in angstroms so a move of 5 is very small. Try to change it to for instance 50 and you should see a change.
Hi Niels,
Thank you for sharing this wonderful package. It's a joy to be able to visualize PDB structures with just a few lines of R code.
I'm writing to ask for your help with a simple question: how can we rotate the view of our structure?
Here is the example I am working with:
Below, the left panel shows the view that I see. The right panel shows the view that I want, after using the mouse to rotate the view 180 degrees.
In other words, I am seeing the "back" of the structure when I want to see the "front" instead.
What's the simplest way to rotate the view?