天道酬勤,学无止境

问答

R - (ggplot) Make geom_step jumps dashed

I'm plotting a discrete CDF. I have a few questions regarding geom_step which I'm not finding by using Google. Is it possible to make the line segment representing the jump dashed rather than solid to better show whats going on? Is it possible to add geom_point more efficiently than I do? (less c/p). Below is my current solution: library(tidyverse) library(ggthemes) theme_set(theme_few()) x0 <- seq(-0.5, -0.01, by = 0.01) x1 <- seq(0, 0.99, by = 0.02) x2 <- seq(1, 1.99, by = 0.02) x3 <- seq(2, 2.99, by = 0.02) x35 <- seq(3, 3.49, by = 0.01) x4 <- seq(3.5, 3.99, by = 0.01) tibble_ex <- tibble(

2022-01-25 05:38:48   r   ggplot2

JFreechart series movement with fixed x-axis

First question here. I'm doing an Arduino serial port plotter with Java and JFreeChart. Everything's working fine with the DynamicTimeSeries dataset, as I'm able to plot data nice and softly. What I need to do now is this: given an established period of time (let's say 60 seconds) I want to plot the DynamicTimeSeries dataset on the chart for that period without moving the axis; I mean, like drawing a line for 60 seconds on the fixed chart. Is there any way to do this? Every example I've watched shows the x-axis (time axis) start running along with the series. If I'm not clear enough please let

2022-01-25 05:38:38   java   arduino   jfreechart

Get size of plot in pixels in R

I am generating a heatmap in R with lots of rows. TL;DR how do I get the real size of a plot in R? df=data.frame(one=1:100,two=101:200,three=201:300) names=1:100 names=paste0("Cell",names) rownames(df)=(names) pheatmap(df,scale="row") default image fits in window, but we can't read row names. pheatmap(df,scale="row",cellheight = 10) changing the cell height lets us read row names but now the image doesn't fit in the window! In this example i am using pheatmap, but also run into this stuff with other plot generating packages. While I've grown to expect frustrating behavior like this from R and

2022-01-25 05:38:32   r   plot   pheatmap

Get generics class loader for parsing nested Parcelable generic field

I have a wrapper of Parcelable generic type but Parcel constructing fails to compile because T class can not be determined generically class MyItem<T : Parcelable> (val model: T) : Parcelable { constructor(parcel: Parcel) : this(parcel.readParcelable(T::class.java.classLoader)) { } } Is there any solution to this case?

2022-01-25 05:38:20   android   generics   kotlin   parcelable

How to format text as a number using the Google Sheets API?

I have a Google Sheet where info in column C is a number that is populated as a string. Example: cell value is '35135.22. In a browser I can highlight column C & select Format > Number > #,##0 and it will convert the string to an number and then format it. (example becomes 35,135) When I attempt to do this using the Google Sheet API (and python) using batchUpdate and numberFormat it does not convert the string to a number. It does format the cell, but because the cell value is still a string, the formatting is ignored. How can I convert a string to a numerical value using the sheets api? (I

2022-01-25 05:38:08   google-sheets-api

Close Bootstrap popover on esc keypress

I am trying to close bootstrap popover using ESC key press. But it does not seem to be working when using: $(document).keyup(function (event) { if (event.which === 27) { $('#example').popover('hide'); } }); Here is the fiddle with bootstrap popover: http://jsfiddle.net/mashinista/b2NKt/

2022-01-25 05:38:03   javascript   jquery   twitter-bootstrap

How to download audio from a video streaming url in the Android SDK?

I need to create an app that allows me to download audio from a video stream in Android. What tools are there that allow me to do such a task?

2022-01-25 05:37:59   android   video-streaming

Google Cloud: can't add disk to instance template with write permission

I am running preemptable instance on Google Cloud. To keep it up, I am using instance group that spawns this instance from an instance template once it gets killed. I want to run Mongo on this instance (I understand that it is a bad idea, it is good enough for me) so I need to add a persistent disk to the instance. When I add a disk to the instance template, the mode radio button is greyed out and set on read-only. There is a warning stating that I can change mode only when manually spawn an instance from a template. It does not help me since I need the instance group to automatically spawn

2022-01-25 05:37:53   google-cloud-platform   google-compute-engine   gcloud

How do I get a hash from an array based on a value in the hash?

How do I grab a hash from an array based on a value in the hash? In this case I want to select the hash that has the lowest score, being potato. I use Ruby 1.9. [ { name: "tomato", score: 9 }, { name: "potato", score: 3 }, { name: "carrot", score: 6 } ]

2022-01-25 05:37:47   ruby

Group by Dynamic Aggregate

In the code below I want to replace x.BaseSalary with any other property whose name is stored in feildtoretrive: var feildtoretrive = "BaseSalary" var groupcal = db.Employees.GroupBy(x=>x.Region) .Select(group => new { Key = group.Key, Avg = group.Average(x => x.BaseSalary) }) .ToList();

2022-01-25 05:37:41   linq   expression-trees