Full Height in heatmapScrollingGridSeries - lightningchart

Hi I want full height in heatmapScrollingGridSeries ,
See the padding on Top , but my line series is covering my full height properly.I tried default Y axis , and even am trying to attach some seperate Y axis to heatmapScrollingGridSeries , but I dont think it uses it. There is always some kind of padding on top of series.
heatmap = chart.addHeatmapScrollingGridSeries({
scrollDimension: "columns",
resolution: 1,
yAxis: customYaxis,
step: { x: 1, y:1000 },
});

I just discovered a bug with current version v.3.1 that might be the cause of your trouble.
It seems that specifically HeatmapScrollingGridSeries can't be attached to any other Axis than chart default axis.
We'll be fixing this for next version v.3.2.
Meanwhile, maybe you can test your usage case by attaching the line series to the other Y axis, and keeping heatmap series on default Y axis.

Related

How to specify axis range without modifying dataset scale?

I would like to know how to set the axis range and achieve the same behavior that Google Image Charts had. Here is the example for the same request URL:
I.e., I have an y value on each 100th of x axis. Is there a way to easily define a dataset 'step' for Image Charts, or I have to create custom labels on x axis with chxl, which I would like to avoid?
Image-Charts founder here :)
Indeed, regarding axis range our documentation is (I hope) explicit:
In Google Image Charts specifying the chxr parameter changed the scale of the axis but not the dataset scale. In Image-Charts — because we think it's was the biggest usage issue with Google Image Charts — changing the axis scale through chxr also impact the whole dataset scale.
You must make an axis visible using the chxt parameter if you want to specify its range.
You will have to use axis range (chxr) to better specify what you want and the steps needed:
chxr=
<axis_index>,<start_val>,<end_val>,<opt_step>
|...|
<axis_index>,<start_val>,<end_val>,<opt_step>

Bokeh Server Plot - How to make new values appear in the center with a fixed axis range

I want to create a plot that shows the live metering data I am getting from an electricity meter.
I already figured out how to have a plot in bokeh, that updates every x seconds with new values, but now I want to have the new values always be at a fixed point in the plot, while the range of the axis does not increase.
I fixed the range by adding x_range=[0, 10] to the figure, however that plot is running out of the screen and I have to manually follow it.
How do I change it so it follows it automatically?
Is that even possible in bokeh or should I be using something different for my project?
Use a default DataRange1d range (i.e. do not set the range to a fixed interval) and then set the follow property on the range. You can also set follow_interval to specify how far back the range should trail the latests data.
p.x_range.follow = "end"
p.x_range.follow_interval = 100
For a complete demonstration see the OHLC ticker example.

How to expand your plot so all labels can be seen without overlapping in R

I have a plot with 50 categories(states) that show on my X axis, but in my output they are on top of each other. I want my plot to be spread out engough/large enough that there is no overlap and you could determine the state value from the next.
NOTE: i used the coord_flip command, so I know that my X-axis is actually my Y in image and vice versa. I am just wondering what function I would use to fix problem.
You can always change the size of the text via themes(axis.text.x=element_text(size=...))...
But the easy answer here is that your plot will change appearance based on the aspect ratio. When you view in Rstudio, you can adjust the size of your plot and you'll see the rearrangement. Additionally, when you save, the plot, play around in particular to the height and width to get the ratio you want. ggsave('filename.png', width=??, height=??).

Usage of layout in R

I'm trying to create this layout for this plot:
layout(matrix(c(1,1,1,1,1,1,
2,2,2,3,3,3,
2,2,2,3,3,3,
2,2,2,3,3,3), nrow=4,ncol=6,byrow = TRUE))
# Set up the top chart that keeps track of the current frame/iteration
# Dress it up a little just for fun
plot(-5, xlim = c(1997,2011), ylim = c(0, .3), xlab = "", ylab = "", main = "Time",axes=F)
abline(v=1995, lwd=5, col = rgb(0, 0, 255, 255, maxColorValue=255))
# Bring back the X axis
xticks <- 1997:2011
axis(side=1, at=xticks, labels=xticks)
# Plot
plot(1:100,1:100)
plot(1:100,1:100)
Obviously the last two plot aren't plot(1:100,1:100)in my real code, but I have a question on usage of layout. Why i get this error on the first plot?
Error in plot.new() : figure margins too large
I want the first picture to have a little height
It might sound silly, but the reason is indeed that the figure margins are too large!
Let me elaborate on this. In R, there are several kind of margins to let your pictures breath:
In your particular case, the margins are eating all the space available, as you try to cram too many figures in the same plot.
To solve this, I would advise to set all the margins to 0:
par(mai=c(0,0,0,0), oma=c(0,0,0,0), mar=c(0,0,0,0))
Which will likely result in your plot to at least be rendered. At the same time, all the subplots will be way too close to each other, so you then have to increase the margins little by little, with similar calls to par(...) until the results looks fine.
Hope this helps :)
The margins are measured in multiples of line-heights via the parameters par(mar), par(oma), and par(mai), as described in this passage in ?par
MAR
A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. The default is c(5, 4, 4, 2) + 0.1.
There are two solutions, you can (a) reduce the margins by setting one of the previous 'par()' settings or (b) you can increase the size of the device, either by re-sizing the device using the mouse if it's a visible device, or if you are printing to PDF, for example, you can set the device size to be larger by setting height and width parameters when you set up the device, as in:
pdf( <<FileNameHere>> , width = par('din')[1],height = par('din')[2] )
I by setting width to par('din')[1] and height to par('din')[2], you get a PDF with the same dimensions as the current device, which lets you make adjustments to the visible device with the mouse. (This is handy for one-off plots and poor practice for a production environment)
If you do reduce the margins, I recommend not setting mar=c(0,0,0,0), as that will result in not having visible axis labels.

My ggplot resizes as I use my Shiny widgets: how to stop this?

The nice thing about using a radiobutton or a slider in an interactive plot is the ability see how output values change as you expand, restrict, or otherwise modify your input values.
With this in mind, it seems natural to keep the size of the plot on the screen constant, AND keep the scale of the x and y axis constant.
In my case, as the selection of points in my bubbleplot change, the dimensions of the ggplot change; that is, the x and y axis shrink or expand to best accommodate data, and/or the physical size on the screen changes. This distorts the radius of my bubbles, stretching or squeezing them.
In an attempt to solve this, I've looked at the 2 obvious places:
mainPanel(
tabsetPanel(
tabPanel("Plot", plotOutput("bubbleplot")), height=1000, width=800))
...which initially sets the height and width, but this doesn't stay fixed as widgets are activated, and...
output$bubbleplot <- renderPlot({
print(getPlot(df, <inputs>))
},
width = 1000,
height = 800
)
...which does the same as above: looks good initially, but doesn't serve as a global control on the length of the x and y axis.
Excuse me for being bold, but it seems like what I'm talking about could be a very, very common topic for people using Shiny -- I guess I'm surprised this simple task is so difficult, and/or this isn't addressed in the Shiny package.
How do I fix the dimensions of plot in Shiny, that stays fixed as I interact with the plot?
Thanks for reading this.
As far as the axis scales are concerned, you need to define them within the ggplot function:
# assuming inside your getPlot() function there's a ggplot() call
g <- ggplot(data) + geom_whatever(etc)
g <- g + ylim(minY,maxY) + xlim(minX,maxX)
g
More info: http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/#setting-range-and-reversing-direction-of-an-axis
Related: I would also like to know how to fix the size of the plot.

Resources