I came across this code to describe use cases for barplot using iris data from library(datasets).
barplot(table(iris$Species,iris$Sepal.Length), col=brewer.pal(3,"Set1"), main = "Stacked Plot of Sepal Length by Species")
The Barplot generated by this R code
I understand how the code works, but I can't figure out what x-axis means. I think the x-axis on bar plots are supposed to be categories/factors. However, in this case, numeric values are displayed and if these are supposed to be lined up by iris species, I don't understand why they would stack on each other.
Could someone explain what x-axis means here and how I can map the data source for generating x-axis when I cannot trace what's displayed on the x-axis in the future?
Thank you!
Related
As you see I am new to stackoverflow and Gnuplot, so please forgive me if I am not asking in the right way or right place ! :-
I have a scatter of (Y) data values/points collected over a range of dates. I can plot them against an x-axis of the dates and I have a 'fit' function of the form f(x)= a*x+b.
My problem is that this function extends/plots beyond the date range of the data points if I plot the data in a window which has a date range beyond that of the collected data. ie. the plotted function fills the whole window.
In other words : I want a window space (xrange) over say 50days but while the data is being collected (a few days only) I want the fitted function to occupy only the region of the so-far collected data and to then extend in sync with it as more data is plotted later.
Am I making sense !
Showing the unwanted
Thanks for any help.
Add a separate range for the fit line:
set xrange [10:50] # applies to the entire plot
plot 'data' using 1:2 with points title "Data", \
[12:25] fit(x) with lines title "fit"
Good day all,
Please am trying to create a SSRS report that looks like the image below
i have my table structure in this manner
Please note the data are not in relation with the chart
But all i could get as a result is a multiple bar chart. that resembles the image below.
Thanks in anticipations of your response
First of all, your "Balance on COC" is negative. That's probably not just a chart visualization issue.
You can format the numbers on the y-axis to be more readable like they are in your first screenshot. Click on the Chart Axis and set the LabelsFormat property to #,0;(#,0).
While numbers in the chart can have up to 16 digits, that is highly unreadable for most people. You might want to consider visualizing the numbers in Billions instead.
To get the labels on the x-axis you'll need to set that field as the Category Group. Then you can delete the legend area from the chart. You can also remove the "Axis Title" areas since they are not needed in this case. This will all make it look more polished like the other image.
I have created a line chart which has the date as X-axis and Y-axis as calculated median value and its grouped according to "FileName". Problem is that some of the "FileName" has same median values which makes line overlap thus not able to see all the lines. Attached image shows only 5 lines but there are total 10 lines. After running query I found out other 5 has 50 as the median which makes it overlap with one of the line.
I tried using transparency and secondary axis but wasn't able to achieve the desired result. Is there any other solution to try out ? Thanks!
This is more of a data presentation issue than something specific to SSRS. If you are stuck on using a line chart, then I've only used two options:
1) Increment lines to different widths. For example, in a chart with 3 lines, the width is set to 5,3,1 pts.
2) Change the values insignificantly to offset the lines. Obviously this depends on the data being visualized as shifting the line slight (multiply by 0.1) may be allowable or highly discouraged depending on your situation.
Trying to do either option with 10 lines (and up to 5+ stacking) is not going to be very good.
I think Viking is right and you might want to check out other visualization options. Grouped column charts perhaps or just split your chart into multiple charts on the page (i.e. four separate trend charts)
Who is the fastest, smartest R user out there??? Easy fix for pros!
I am creating a horizontal barplot and displaying results from traits as a percentile. The industry I work in has the 100th percentile as the lowest and zero the highest. So that is no problem plotting that as you can see with my current command: barplot(mydata$Percentile, names.arg=mydata$Trait,horiz=T,las=1,xlim=c(100,0),base=50)
abline(v=50, lty=2)
Current version
Currently I have the 100th percentile on left and zero on right. The bars on the plot however come from the right hand side of the plot.
PROBLEM: I would like them to start from 50. For what I am looking to do please see the picture attached from a MATLAB example where they have set the base value at 25. MATLAB example
One possibility to solve this is to subtract 50 from your values and plot this without axis.than you adapted your axis:
values <- c(100, 10, 55, 30, 120)
barplot(values-50, horiz=T, axes=F)
axis(side=1, labels=seq(0,120,20), at=seq(0,120,20)-50, xpd=T)
ps: I guess your first lines, the opening, prevent a lot of people to answer.
I have a bar chart that show the count of number of models for each agency,
The problem is that I have a large difference between the values that makes the report to look not so good.
Does anyone have any ideas of a good way to resolve this problem?
Have you considered using a logarithmic scale?
With your chart Right-click the y-axis, and click Vertical Axis Properties.
In Axis Options, select Use logarithmic scale.
Leave the Log base text box as 10 (this is the scale most commonly used by logarithmic charts)
This will display a chart with a scale that goes up by a factor of 10 for each ‘unit’ up, so the distance between 1 and 10 is the same as that between 100 and 1000.
For example the shown dataset is displayed as this chart when using the logarithmic scale
This method is a simple and recognised way to clearly show values of widely different scales.
Update
If want an indicative bar for the vales that are 1 then you could use the expression
=iif(Fields!val.Value = 1, Fields!val.Value * 1.1, Fields!val.Value)
To make all values that are 1 equal to 1.1 so showing a tiny bar appearing a the bottom of the chart, as seen here
Unfortunately I don't know of a way to change that first 1 to a zero (formatting-wise). This is partly because you are now using a logarithmic scale and zero and negative values don't really exist. This is due to a fundamental property of logarithms in mathematics, that
LOG10(10)= 1
LOG10(1) = 0
LOG10(.1)=-1
Therefore, when you perform a log10 of zero, it just doesn't exist.