Adding More Tick Labels To ZedGraph Axis? - zedgraph

I have tick labels on about every 4 ticks. This is great, but I want labels on every single tick, and I want to say that each tick should be an hour apart.
How can I accomplish this?

Edit properties of the Scale of your XAxis:
to change the gap between ticks edit the MinorStep and MajorStep properties. For both, use the value that corresponds to your one-hour-gap.
to display labels at every tick, AFAIR you should set IsPreventLabelOverlap to false.
try also editing MajorTic and MinorTic of your XAxis
Remember to call AxisChange() method and Invalidate() or Refresh() in order to refresh your graph with new scale settings.
If you have long labels, it is also useful to set the Angle property of FontSpec to 90 to draw long labels vertically, instead of horizontally (it saves a lot of space).
More info:
http://zedgraph.sourceforge.net/documentation/html/T_ZedGraph_Scale.htm

Related

Stop .Net Chart (DataVisualization) From ReSizing To Tiny Chart?

I have a chart that has strings for its x axis (a list of names). It's linked to a dynamic array, I have a problem where the graph resizes itself and squeezes 14-15 strings from the array and makes the bar chart small and tiny.
How can I achieve chunky bars and a scroll bar to scroll down to see the rest of the data even when new values are being added to the x-axis at runtime.
Have spent an hour searching with no help! =[
Edit:
Setting the PixelPointWidth Property to 300 gave me the width of the bar the way I want to be, but it has bunched the bars so that all the bars of the 4 series are overlapping instead of being side by side. WHere to go from here?
Edit2:
Manipulating the charts height is definitely getting the desired results, the only thing is the bigger the height, the more white space at the top of the chart, whats the fix for that,. and a fix for the Series representations to be "frozen" on scroll.
You can set the width of the chart every time you add new data to it:
Dim barWidth = Double.Parse(Chart1.Series(0)("PixelPointWidth"))
Chart1.Width = CInt(nData * barWidth) + 100
where nData is how many points there are and the 100 is some amount to take into account the space needed for the Y-axis labels and the legend.
Place the chart control in a Panel as suggested by jmcilhinney with AutoScroll set to true, and you will get a scrollbar when the width of the chart exceeds the width of the panel.
If you want the chart to show the latest added data, you can set the horizontal scroll position after setting the width of the chart:
Panel1.HorizontalScroll.Value = Panel1.HorizontalScroll.Maximum

Scale domain vs filter selection in vega-lite: automatic axis scaling

In Scale Domains docs of Vega-Lite it is noted:
An alternate way to construct this technique would be to filter out
the input data to the top (detail) view like so:
{
"vconcat": [{
"transform": [{"filter": {"selection": "brush"}}],
...
}]
}
Which is indeed almost the same (although filter method being much slower, as noted in the docs), except for one difference:
With filter-selection method (demo), the y-axis of the upper chart will be automatically zoomed in to the selected points. This is pretty neat, especially if you have large amount of points.
With scale-domain method (demo), the y-axis remains frozen as you move the selection around.
The question: is it possible to have the y-axis automatically zoom in to the selected points as you move the selection, with "scale domain" method (same as it does with filter-selection method)?
Why is the above difference important? Imagine a stock price that has been increasing on average by a total of $1 every day last year (but within a particular day it may have experinced any kind of volatile behaviour) and we're plotting it with line marks. If you plot the entire year, you see the whole picture. If you zoom in on a particular day without resetting your y-axis zoom, however, your intraday price plot will be just a flat line, or close to that.
// I've checked all scale-domain-related issues on vega-lite, on altair repo and SO and couldn't find anything related; I've also posted this question on vega-lite repo on GH, but was forwarded over to SO.
No. Unless otherwise specified, the y scale is determined from all of the data within the plot.
When you filter the data, the data in the plot changes, which causes the y axis to change. When you change the scale based on an x-selection without filtering the data, it does not change the data in the plot, and so the y scale remains constant.
If you want the y-scale to be determined automatically based on the data within the selection, the only option is to filter on that selection.

Programmatically set drawCircle on a per value basis on LineChart

Is there a way to toggle drawCircle on individual data points? From the documentation it appears you can only enable this at the dataset level. I'm trying to draw circles for the min/max of a dataset.
If there isn't a way to draw circles on individual data points another workaround I've tried implementing has been to create a second dataset and only plot the corresponding X index and min/max Y value; every other value is set small enough that it is not visible in the viewport. The only problem here is I can't seem to plot both datasets without overwriting the first dataset's background fill.

core plot stacked graph crossing top border

I'm trying to create a stacked graph using core plot.i have followed this tutorial.I have a UISlider on sliding i'm updating my graph.The issue i'm facing is my top value for y-axis is touching top border(As in the screen shot). As per my requirement in need to round off the highest value to next 10th value so that my graph doesn't touch the borders.On changing my slider value the x and y axis should also get refresh,i'm doing it by regenerating plot but it takes a lot of memory.Any idea how can i achieve these requirement ?
Don't recreate the whole graph every time the values change. Call -reloadData on the graph to refresh the plot data and set the xRange and yRange of the plot space to change the scale of the axes.

How can I get and set the position of a draggable legend in matplotlib

I'm trying to get and set the position of a draggable legend in matplotlib. My application consists of an interactive GUI, which has a redraw/plot function that should perform the follow steps:
save the position of the current legend.
clear the current axes and perform various plotting operations, which may or may add labels to their plots.
build a new draggable legend (ax.legend().draggable()) and restore the old position of the legend.
In between these steps the user is free to drag the legend around, and the goal is to persist the legend position when the plots are redrawn.
My first approach was to use oldpos = legend.get_bbox_to_anchor() and legend.set_bbox_to_anchor(oldpos) in steps 1 and 3. However this causes to move the legend completely off the visible area.
Note that I have to use ax.legend() and cannot use fig.legend(lines, labels), since step 2 is completely decoupled, i.e., I don't know anything about lines and labels in step 3. According to answers to the question How to position and align a matplotlib figure legend? there seems to be a difference between these two possibilities regarding axes or figure coordinates. Obviously my problem calls for figure coordinates, but I haven't fully understood how to convert the bbox to a "bbox in figure coordinates".
The even more severe problem I just realized is that apparently legend.get_bbox_to_anchor() always seems to return the same values irrespective of the drag position. So maybe the anchor can only be (ab-)used to manipulate the position of static legends? Is there another/proper way to save and restore the position of a draggable legend?
By looking at the implementation of Legend I found out that there is an undocumented property _loc, which exactly does what I want. My solution now looks astonishingly simple:
oldLegPos = ax.get_legend()._loc
# perform all plotting operations...
legend = ax.legend().draggable()
legend._loc = oldLegPos
It looks like _loc automatically stores figure coordinates, since I do not have to convert the coordinates in any way (eg. when the plotting operations completely change the axes ranges/coordinates).