I am using react-chartjs-2. I have a Line chart and x: time y: value. I have 2 different dataset. First dataset value is very as low as 0.00000145 and etc. The second dataset value is as high as millions. When i use this in the same chart, first dataset is at the bottom and looks like a single straight line as chart comparing 2 datasets. Time is same for both datasets. So what is the best way to see two different datasets self comparing?
I think, the best way is to make single chart, which will show correlation between two datasets - the division of first dataset's values by another's. I think, it may be representative
Related
There are 2 sheets: Data and Stats. Data contains records (several hundred) that are divided into ~20 categories. On the Stats sheet, I want to do various calculations. Is there a way to compose formulas in a way to take in only the categories that are enabled?
Previously, this was implemented in Excel, where SUMIFS function makes it possible (the conditions are inclusive). But in GS SUMIFS does not evaluate further conditions if condition1 is true. Or: I'm doing something wrong. Totally possible.
=SUMIF(Data!K:K, "<="&G3, Data!N:N) This version is a single condition. It says 'give me the sum of N column on Data sheet, provided corresponding value of K is less than or equal to G3'.
SUMIFS(Data!N:N, Data!K:K, "<="&G3, Data!B:B, G2:G20) (the syntax is slightly different in comparison with SUMIF)
Here, range G2:G20 contains the list of categories that I want to be able to switch on and off, and B column contains category labels. In Excel, when you indicate a range like this, it works. In GS - not so much.
Regardless of the Excel implementation, what would be the best way to achieve this on/off functionality in Google Sheets?
try:
=SUMPRODUCT(FILTER(Data!N:N, Data!K:K<=G3,
REGEXMATCH(""&Data!:B:B, TEXTJOIN("|", 1, G2:G20))))
note that G3 is overlapping with G2:G20 so something is not right in your referencing tho
I have a sf polygon dataframe with multiple
series (T1, T2, T3, all on the same scale:
they're observations at different time points).
I can plot say T1 with
ggplot(map)+geom_sf(aes(fill=T1))
what I'd like to do is plot all three (T1, T2 and T3)
as facets (separate maps) on the same drawing.
I'm sure there's a way to do this, but I can't find it.
Can anyone tell me how? Thanks!
ADDED: Two additional notes on this question.
First, the data structure described above is
one that could be plotted using spplot, with
the T's being the arguments to spplot's zcol argument.
So in this connection, my question amounts to
asking how to convert an spplot structure to
be usable by geom_sf.
Second, suppose I use sf to read in a shp file
for say 20 polygons. I also have a data frame
consisting of stacked observations for these
same polygons, say for 3 periods, so the
dataframe has 60 rows. How do I merge these
in order to be usable? Can I just stack
3 copies of the sf structure, and than cbind the
dataframe (assuming the rows match up correctly)?
At least in one sense this turns out to be very simple. Given a data structure (ds_sp) that can be plotted with spplot, you can just do the following:
ds_sf <- st_as_sf(ds_sp) # convert to sf form
plot(ds_sf[c("T1","T2")]) # plot the desired series
This isn't quite the same as using facet_wrap with ggplot, but at least it gives you something to work with.
ANOTHER LATER ADDITION : As to the longitudinal + facet_wrap issue, the following seems to work:
If necessary, create a data frame (df1) with the
longitudinal data (longit), an area indicator (fips) and a time
indicator (date) which will be used for faceting, and
anything else you may need.
If necessary, create an sf-compatible version of
the spatial geometry via st_to_sf, as new_poly .
This will be of classes "sf" and "data.frame"
and should have a spatial indicator matching fips
in df1.
Merge the two:
data_new<-df1<-dplyr::inner_join(df1,new_poly,by="fips",all.x=TRUE)
Now produce the plot
ggplot(data_new)+geom_sf(aes(fill=longit,geometry=geometry))+facet_wrap(~date)
and make adjustments from there.
Consider the following table
I need to generate a bar chart with the Category Group = "Country". The chart should only display the top 3 Groups based on the count of records for a country. I have already applied a filter for the Category Group specifying the Top N Condition as 3 for Count(Country). The chart generated, applies the filter as expected based on count, but i need only 3 bars to be shown even if there are bars with duplicate values.
Below is the chart that I get.
Expected Result
Now I know that, i can create an additional column in my dataset with ranking values and then apply a filter on this column to get the expected result (i have tried this, and it works)
Is there a way to achieve the expected result without changing the underlying Dataset?
Note: The dataset shown above is a highly simplified version of my dataset. In reality i have a huge dataset with a lot of columns. The same dataset has been used for various charts (with groupings on different columns).
This was an interesting question as I've always just "solved" the tiebreaker in the dataset without much thought. However, I do see a fairly easy way to use the rnd() function to dissolve the ties as long as you don't care which of the tied countries is shown:
=(Count(Fields!Country.Value) * 1000) + (Rnd() * 100)
Which essentially just weights the count per country into the thousands and then tiebreaks with a random small value:
New York: 30XX
France: 20XX
China: 10XX
Italy: 10XX
Singapore: 10XX
If you wanted to actually solve the tiebreaker with an alphabetical preference, you could do something similar but incorporate the numeric value for the first letter of the country etc...
I just found out, I could use an x-axis minimum of 0 and an maximum of 10.5 together with an interval setting of 1.
So, I was able to achieve a top 10 limitation and the axis labels show the names - (it may be a side effect but when I changed the axis maximum to a whole number, the axis no longer shows the names but numbers).
I was not really happy with the other approaches. They seems much of an overkill to me for such a simple requirement like limiting the number of bars shown in a chart.
I'm trying to compare line graphs with completely different values and scale.
On X-axis i have values from 0-30 (Days) and on Y-axis i have stock values.
My task is to compare the data of last 30 days with a huge database which already contains different stock values.
is there any way to compare the shape to 2 graphs irrespective of what values were used in y-axis?
Thanks in advance
First Graph
Second Garph
I have a SSRS 2008 report with a Error Bar chart. It plots dates (x-axis) versus score (y-axis), with +10/-10 for the upper/lower error range. But in the dataset, I also have two sets averages (the US and the company's).
I would like to display these averages as a constant. It should be a horizontal line that runs through the chart.
In the chart, I have as category field: the date. As datafields: the score, the US average score, and the company's average score. Thus far I can plot all these points, but it seems that the averages' points are plotted simply as points, and are treated as points that should have upper/lower error ranges.
My question is, how can I get these averages to not display as points with ranges, but as a linear constant that is connected as a straight line? It seems as though with the Error Bar chart, it only wants to plot points with ranges.
(I have screenshots of what I have and what I want, but my work is blocking any image hosting sites. I will try to upload images later if this is still unclear.)
Thank-you in advance.
(Update)
Just to be clear, the two averages aren't calculated out, they exist as a column as part of the dataset retrieved. So for each row, these values are always the same.
It turns out that each series in the SSRS chart, you can change the chart type. In my case, I had to change it to Line graph to get the constant to show as a horizontal line.
So although the chart itself is a Error bar chart, each of the series can be changed to whatever bar chart needed.
(It was my co-worker that discovered this property-- so props to him)