I use ggplotly in my shiny app and use the layout function for the title. When I want to pan the picture, the title and images stay on the same spot while the plot is moving.
Is there a way to let them move with the plot? I know the pan function is to look at parts of the plotted values, but I also got info in the images and title. Besides that, I want the plot to be a certain size, even on mobile and than I need the plot to be able to scroll.
MRE:
library(ggplot2)
library(plotly)
plot<- ggplot(iris,aes(Sepal.Length,Sepal.Width)) + geom_point()
ggplotly(
plot,tooltip="text")%>%
layout(title = list(hjust= 0.5,text = "Title"))
Adding the title through ggplot doesn't solve this.
EDIT:
I made a scrollable box, which solves it a little bit. I want to use the whole plot to scroll when there is a finger/cursor clicking and moving.
Otherwise an other solution is just setting the aspect ratio of the plot instead of the absolute size. Anyone know something about that?
Related
I am drawing a picture of go annotation result using ggplot2, i want to add three open boxes underneath the X axis label to identify the main classes of go annotation. Is there anyone can help me? The picture just look like that as below.
I've been trying to add different colored shapes to the background of plotly.js. However, I also want to be able to label them somewhere so the user knows what color has what meaning. How can I do that?
The first example on here is basically what I've got so far:
https://plot.ly/javascript/shapes/
I'm using heatmaply() to create an interactive heatmap for Shiny. I encounter a few challenges when using cellnote = "some values":
cellnote starts in the center of the relevant tile of the heatmap by default. How to center it? (This is particularly frustrating when numbers start to overlap with the next tile)
How to ensure that the cellnote is not top alligned? (notice it's almost as if the cellnote is placed in the top right of the cell)
How to use a smaller text font (e.g. like notecex in heatmap.2)?
When using cellnote the ability to hover in shiny only exists if you hover on the edges of a tile. It is as if the cellnote is placed on top of the heatmap and blocks some of the area of the tile such that the hover ability does not activate. Is there a fix for this?
For a visual of what I mean regarding cellnote:
Cellnote not centered
1 & 2: Try the cellnote_textposition argument in heatmaply. It adjusts both horizontal and vertical justification.
3: I've created an issue for this. Thanks for pointing it out!
4: This is a known issue and we would hope to resolve it eventually, though it is quite difficult to solve, unfortunately.
If I have a graphic composed of several plots, say three plots arranged vertically. This is a gtable object and can be drawn to the page with:
grid::grid.newpage()
grid::grid.draw(plot)
However I see that the plot in my RStudio is 'smushed up' as in the screenshot below:
As you can see in the bottom right corner it is squashed and the titles overlap with other elements of the graphic.
If I hit zoom and view the plot it is a lot bigger:
Now I know, that if I were to export my gtable plot using pdf() or png() and such devices, I can set a width and a height, and so just make it big enough such that the plot is not squashed.
However, instead of one of those graphic devices, I would like to use export.grid, from the gridSVG package to save it to an SVG file. But if I do
gridSVG::export.grid(plot)
Then the SVG file exported looks squashed as it does in the RStudio plot window.
So my question is, how can I manipulate the dimensions of the graphic so it is drawn to SVG without it looking squashed? I draw the plot initially with grid.newpage and grid.draw, I wonder perhaps I have to specify some size of the page or drawing using grid.
Thanks,
Ben.
I would like to be able to specify the placement of a legend for a linechart. Currently, it continues to appear to the right of the chart. I have tried playing with the width/height of the chart to no avail... Putting the legend before the linechart in the mxml causes it to appear to the left. I can't seem to get it appear at the bottom though. I can't seem to find any good examples for this. They don't seem to specify anything but the legend usually shows up below the chart, I can't seem to do it. Optionally, it would be okay to somehow minimize the legend..
what container are your line chart and legend in? its sounds like you are using either an HBox or an application with the layout="horizontal". To move the legend below use either a VBox or application layout of vertical. Or you can use a canvas and use constraints (left, right, top, bottom) or x and y coordinates