Scale chart Y axis labels - vb.net

I have a vb.net windows form chart control on a form that displays a line chart of data that is made available in milli-gravities.
e.g. 5 gravities is given as 5000 milli-gravities, meaning that the Y-axis label is 5000
Is it possible to plot the same data but, have the Y-axis use labels in gravities, instead of milli-gravities? That is, for a Y data point of 5000, the Y axis label should be 5, or in other words have label value = auto label value / 1000
The data is currently bound to the chart using the following syntax
Chart1.Series.Add("Z Axis") 'Add multiple series
Chart1.Series.Add("Z RMS")
For Each Series In Chart1.Series 'Set each series to line type
Series.ChartType = SeriesChartType.Line
Next
Chart1.ChartAreas(0).AxisY.Maximum = 100000 'Start the Y axis limits at 100 gravities
Chart1.ChartAreas(0).AxisY.Minimum = 100000 'The max & min are changeable by user input
Chart1.ChartAreas(0).RecalculateAxesScale()
Chart1.Series("Z Axis").Points.DataBindY(record.Samples, "Z") 'Add the Y data points
Chart1.Series("Z RMS").Points.DataBindY(record.Samples, "RmsZ")
I thought maybe setting the Chart1.ChartAreas(0).AxisY.LabelStyle.Format might help, but I'm not sure how to use a format string to shorten an integer?

Related

How to connect points with different indices (one data file) in gnuplot

I have a file "a_test.dat" with two data blocks that I can select via the corresponding index.
# first
x1 y1
3 1
6 2
9 8
# second
x2 y2
4 5
8 2
2 7
Now I want to connect the data points of both indices with an arrow.
set arrow from (x1,y1) to (x2,y2).
I can plot both blocks with one plot statement. But I cannot get the points to set the arrows.
plot "a_test.dat" index "first" u 1:2, "" index "second" u 1:2
From version 5.2 you can use gnuplot arrays:
stats "a_test.dat" nooutput
array xx[STATS_records]
array yy[STATS_records]
# save all data into two arrays
i = 1
fnset(x,y) = (xx[i]=x, yy[i]=y, i=i+1)
# parse data ignoring output
set table $dummy
plot "" using (fnset($1,$2)) with table
unset table
# x2,y2 data starts at midpoint in array
numi = int((i-1)/2)
plot for [i=1:numi] $dummy using (xx[i]):(yy[i]):(xx[numi+i]-xx[i]):(yy[numi+i]-yy[i]) with vectors
Use stats to count the number of lines in the file, so that the array can
be large enough. Create an array xx and another yy to hold the data.
Use plot ... with table to read the file again, calling your function
fnset() for each data line with the x and y column values. The function
saves them at the current index i, which it increments. It was
initialised to 1.
For 3+3 data lines, i ends up at 7, so we set numi to (i-1)/2 i.e. 3.
Use plot for ... vectors to draw the arrows. Each arrow needs 4 data
items from the array. Note that the second x,y must be a relative delta,
not an absolute position.

How to set in range in hexbin plots pandas?

I want to set range of y-axis in the following code.My values are [19,20,21,22,23,24.....,40].I want the labels to be starting from of difference 10,starting from 10 upto 40.How should I set that.
I was trying to use x-lim but it is not working.
plt.hexbin(p_df['Age'], p_df['Salary'], gridsize = 50,bins ='log',cmap ='BuGn',xlim =(19, 40))
To set the range of values to include in the binning, you must use the 'extent' keyword. So to have a hexbin plot with a range between your desired x and y values, you can use,
extent=[-x,x,10,40]
where x is your included x coordinates.
So your new code would be
plt.hexbin(p_df['Age'], p_df['Salary'], gridsize = 50,bins ='log', extent=[-x,x,10,40],cmap ='BuGn')

how can i plot a graph in in vb to to show a large amount of data

I want to plot graph to show the difference of Net connectivity in one hour . i found the average speed of One hour and the different between the Speed. and i add the difference percentage in a ListBox . I have to show the numbers in graph of one hour ? How can I Plot the Graph Any Suggestion Please .
enter code here
Dim Per As Double
For x As Integer = 0 To ListBox2.Items.Count - 1
Per = Math.Abs((avg - Val(ListBox2.Items.Item(x).ToString)) / (avg)) * 100
ListBox3.Items.Add(Per)
i have to plot all the number of ListBox3 contains more than 3000.
i found it...
For y As Integer = 0 To ListBox3.Items.Count - 1
s.Points.AddXY(y, Val(ListBox3.Items.Item(y).ToString))
Next
Chart1.Series.Add(s)

VB2010 Setting logarithmic scale intervals

I'm developing a financial application in which I need to display data in a chart with a logarithmic scale on the Y axis. Everything works fine except for the intervals. With the following:
chart.ChartAreas(0).AxisY.IsLogarithmic = True
chart.ChartAreas(0).AxisY.LogarithmBase = 10
chart.ChartAreas(0).AxisY.Interval = 1
chart.ChartAreas(0).AxisY.Minimum = CalcMinYVal(minYVal)
I get the CalcMinYVal multiplied by 10^0,10^1,10^2,10^3 and so on for the Y-axis values.
I would like to have the Y axis values increased by 1. How can I have the interval be REALLY 1?
You can enable the MinorGrid property
chart.ChartAreas(0).AxisY.MinorGrid = True
to show the horizontal lines in between the powers of 10 like shown below.
But there is a limitation in showing the value for each subdivision. They can only appear in fixed intervals by using the Interval property of the LabelStyle.
For example to show 10 subdivisions, you can set:
Chart.ChartAreas(0).AxisY.LabelStyle.Interval = 0.1
The number of the horizontal lines of the MinorGrid can be controlled by using its Interval propery:
Chart.ChartAreas(0).AxisY.MinorGrid.Interval = 1
and the values of the labels can be rounded by using the format property:
Chart.ChartAreas(0).AxisY.LabelStyle.Format = "{0.0}"

Bar and Line charts are not synced when in the same chart area

I have problem with a chart in vb.net. The problem is that line and bar are not synced in the chart area. I've attached a picture to make it clear what I mean
Here is the code where I populate the chart. I´m getting the data from a database.
Dim theDate As Date
For i As Integer = Count - 1 To 0 Step -1
'Chart1.Series("serRxTime").Points.AddY(dv(i)(0) / 60)
theDate = dv(i)(1)
Chart1.Series("serTime").Points.AddXY(theDate.ToString("dd-MMM HH:MM", enUS), dv(i)(0) / 60)
Chart1.Series("serAdd").Points.AddY(dv(i)(2))
Next
Line and column series have the same XValues that's why their centres are aligned. You would need to generate different XValues for the two series. XValues that are offset by a small margin. Something like this:
Chart1.Series("serTime").XValues = {0.8, 1.8, 2.8, 3.8,,...,count - 0.2}
Chart1.Series("serAdd").XValues = {1, 2, 3, 4,..., count}
I used 0.2 difference, but this will be different in your case (especially since it seems you have date axis set?). This would push the line series to the left.
I created an example for you. On the first picture you can see the data for the columns. Their x values are 1,2,3,4,...,12 and their y values are marked with blue.
And this is the values for the XY chart. As you can see I moved the x values by 0.2 to the left.