I'm working with core-plot and having problem with the x axis' customization .
I want x axis' labels to display some dates but they don't have an equal difference . For example , the dates may be like this : 2012-05-06 , 2012-06-08 , 2012-07-21 ... So I think I can not set the axis labels by setting the major interval . Can anyone tell me the way to do this ? Any suggestion will be appreciated !
Yes,If those dates are consecutive value means You can achieve this while creating a custom label. You can add your consecutive dates into an Array and set this array to majorTickLocations property of your X axis.
following line add into your custom label generation method. customStick is value u wanted to set.
[customTick addObject:customStick];
add this line in your axis property set.
axisSet.xAxis.majorTickLocations = [NSSet setWithArray:customTick];
Related
My dataset has WeekEndingDate and Sales. I am displaying a straight table with all the selected data but I need to have another table showing the following:
Sales (other columns...)
First week : 1,000
Last week : 1,350
Difference : 350
Difference %: 35%
My questions:
a) Can I have the above in one chart/table, or I need 4 different charts showing columns filtered by set expressions?
b) My strategy is having 2 variables (vMinWeek and vMaxWeek), and using them in set expressions. Is that the best route?
c) My set expressions (below) are not working - they sum the whole data set. Would you please help me understanding why?
=max ({$<WeekEndingDate={'$(vMinWeek)'}>} Sales)
Thank you for your help!
Mara
I think the reason your set isn't working is that your WeekEnd date is formatted as a date and your variable is formatted as a number.
The trick with Set Analysis is always to think what you would have to type in a list box to get to your answer. So even though QlikView stores WeekEnd 2014/08/18 as 41869 you can't type 41869 in the WeekEnd list box and get back that date. So I would make your variables of the form =date(min(WeekEnd)).
The second part of your question; getting the table you want. I would do like this. I make a loose table with the dimension values, dual is so that it sorts correctly in the chart we are going to build.
load dual(D,N) as DIM inline [
D,N
First Week,1
Last Week,2
Difference,3
Dif %,4
];
I like defining my variables in the script as well, so I would do this.
set vFirstWeek='=date(min(WeekEnd))';
set vLastWeek='=date(max(WeekEnd))';`
Then when building the straight table we use the dimension as DIM but because DIM isn't connected to anything we have to do some work to get it to display values that fit those dimension values. The num(,'# ##0') is just to format the % differently from the sums. For this to work the number format in the Number tab of the chart must be set to Expression Default.
if(DIM='First Week',num(sum({<WeekEnd={'$(vFirstWeek)'}>} Sales),'# ##0'),
if(DIM='Last Week',num(sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'# ##0'),
if(DIM='Difference',num(sum({<WeekEnd={'$(vFirstWeek)'}>} Sales)-sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'# ##0'),
if(DIM='Dif %',num((sum({<WeekEnd={'$(vFirstWeek)'}>} Sales)-sum({<WeekEnd={'$(vLastWeek)'}>} Sales))/sum({<WeekEnd={'$(vLastWeek)'}>} Sales),'0.00%')))))
I am trying to plot a list of 30.000 values. The name of the list is "velocity_x". I just plot them with the following command:
plot(velocity_x,'r')
the result is shown in the image below (do not pay attention to the dashed line)
Since I am using that command line, it creates automatically a x-axis of length 30.000. What I would like to do is changing the range of my x-axis in such a way to show the time(s) instead of the iterations where t = 0.0002 * iteration.
You could use linspace:
a=np.linspace(0,6,len(velocity_x))
plot(a, velocity_x, 'r' )
You can set the values by setting 'Xticklabel' see here.
You want to do something like
h=gca; %get current axis if you dont have it as a handle already.
set(h, 'Xticklabel', 0:5000*0.0002:5000*0.0002*7); %set correct ticks.
You could also try something along the lines of
plot( [i*0.0002 for i in range(len(velocity_x))], velocity_x, 'r' )
I have a case where data presented on the chart is gathered in five minutes interval during the working hours, while at night it stays idle. When the chart presents data from a couple of days, there are obviously a flat lines between days (during nights).
Using category axis solves the problem with long steady lines during nights. However using time axis I was able to format date and use time interval property.
How can I do that using category axis? I mean formatting tick labels and achieve similar behaviour to using time intervals?
That is how it looks like at the moment using category axis:
I would like to present just one tick for every day, properly formatted.
Thank you in advance for any help.
You can do this by using a grouped category axis, It will involve a little manipulation of your dates into a separate time part and day part using some code like this:
// Create a d3 parser for this particular date format, this may not be relevant
// if you already have actual dates
var inFormat = d3.time.format("%Y-%m-%d %H:%M");
// Create a d3 parser for the day and time formats we are going to use
var dayFormat = d3.time.format("%d %b"),
timeFormat = d3.time.format("%H:%M");
// Add some code to manipulate the date into 2 separate fields
// because this is a category axis you need to handle formatting here
// category axes use text content
data.forEach(function (d) {
// Convert the date to an actual date, you may not need to do this if
// you already have date objects in your data
var inDate = inFormat.parse(d.Date);
// Add a new field for the time portion
d["Day"] = dayFormat(inDate);
d["Time"] = timeFormat(inDate);
}, this);
Here it is in context doing what I think you want:
http://jsfiddle.net/87GHM/1/
I have a datafile with multiple columns, the first two indicating the position and the others indicating other properties (such as number of items sent from this point). eg:
1 1 1 57.11
2 1 2 62.40
3 4 1 31.92
What I want to do is plot the points at the positions, but use values from the other columns to vary point type and size (for example). However I can't seem to find a way to reference columns in the plot. I know of the use of "variable", but I cant find a way to use multiple variables.
What I want is something like the following:
plot "mydata" using 1:2 notitle with points pt ($3) ps ($4/10)
so that pt and ps use the value for each point taken from the third and fourth columns respectively.
Is this even possible in gnuplot? Is there some sort of work-around?
You should be able to use the keyword variable to do something like this:
plot 'datafile' using 1:2:3:4 w points ps variable lc variable
Or possibly mapping the value to a palette:
plot 'datafile' using 1:2:3:4 w points ps variable lc palette
The keyword variable and/or palette causes gnuplot to read the properties from the file and they both require an extra column to be read via using. Of course all the usual stuff with using applies -- You can apply transforms to the data, etc:
plot 'datafile' using 1:2:3:($4+32.) w points ps variable lc palette
I don't remember off the top of my head whether the 3rd column will be the pointsize or the color here, and I don't have time right now to play around with it to figure it out. You can do the experimenting and post a comment, or I'll come back to this when I have time and add an update.
Some of the other properties (e.g. pointtype) can't be changed quite to easily using variable. The easiest way to do this is to use filters with the gnuplot ternary operator.
First, write a function that returns a pointtype based on the data from 1 column of the datafile:
my_point_type(x) = x
Here I use a simple identity function, but it could be anything. Now, you can loop over the pointtypes you want (here 1-10) making a plot for each:
plot [for PT=1:10] 'datafile' u 1:((my_point_type($3) == PT) ? $2:NaN) with points pt PT
This assumes that the column with pointtype information is the 3rd column and that the second column holds the position information. This can also be combine with the stuff that I demonstrated above.
I have a 2D dojox.chart. I want to label tick marks on the X axis with dates that have time and date on separate lines. Is there a way to achieve that?
Yes, there is quite a simple way. Just add a <br/> tag between your date and time in your labelFunc or in the text for values that you generate:
labelFunc: function(value){
return value +"<br/>"+"sometext";
}