Remove blanks at ends of DataVisualization chart x axis - mschart

I am using Microsoft's DataVisualization.Charting.Chart, and I have integer values along the X axis, using line-style graphs. However, the chart is adding an extra blank item at the beginning and end of the x-axis, with no value labels to explain what they are.
How can I remove these empty items and make the lines go right up to the ends?

Use the IsMarginVisible property of the xaxis. I believe that will do the trick.
To test this, I changed one of my own charts to be a line chart and then set the value in the code:
ReactivityChart.ChartAreas(0).AxisX.IsMarginVisible = False
Tell me if this is what you were hoping to get or if I have totally misunderstood the question:
(note that I do not have a high enough rep to post this image)
http://www.rectorsquid.com/chartmargintest.gif

You should set the Maximum and Minimum properties in ChartArea.AxisX, e.g. :
this.chart1.ChartAreas[0].AxisX.Minimum = 0; // if your minimum X = 0
this.chart1.ChartAreas[0].AxisX.Maximum = 100; // if your maximum X = 100
In this way, your chart area will show only the values between Minimum and Maximum.

Related

How to get/set vertical scroll filter property in OBS using C++?

It is necessary to get/set the value of the vertical speed property. The verticalSpeed property has a value of 500 (the maximum value of the slider), but in OBS I manually set 35.
How to get exactly the value 35?
A second question, how can I see all the available filter properties?
obs_data_t* source = obs_get_source_by_name("SOURCE_NAME");
obs_data_t* filter = obs_source_get_filter_by_name(source, "FILTER_NAME");
obs_data_t* settings = obs_source_get_settings(filter);
vspeed = obs_data_get_int(settings, "verticalSpeed");
Thank you for any help!
Ok, there is an GetSourceFilterInfo function that returns a list of filter properties.
Speed is a parameter speed_x and speed_y.
https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#getsourcefilterinfo

Python:How to do operations on a grid

For a word game(something similar to image provided),where inside a grid various letters are entered on different tile,enter image description here I had to create a 6*6 grid and then do operations on it like:
a)place the tile on a specific location in the grid and
b)return the location of any tile on the grid
c)determining the top scoring words in the grid
Till now I have managed to create the grid but i have no clue of how to place a tile on a specific grid or fetch the location of a tile on the grid.I have created the following grid:
grid = [[" _" for x in range(6)]]
for y in range(6):
list1 = []
for x in range(13):
if x%2 == 0:
list1.append("|")
else:
list1.append("_")
grid.append(list1)
for row in grid:
print("".join(row))
I am new to python and any help would be appreciated.
Did you try to run this piece of code? I don't think so because the indentation here is bad, so it won't work.
You should rename your variable list1 to row for comprehension
purpose : your variable names should always be as descriptive as
possible.
Here to initialize in a more compact way your grid you could do:
grid = [["_" if x%2==0 else "|" for x in range(13)] for x in range(6)]
To access a specific tile you can do:
grid[y][x]
In example, the following command would print the cell on the third row second column:
print(grid[3][2])
To set the value you can do:
grid[y][x] = value
But I think that you should see a course about learning Python before trying to do these things.
Google it and good luck!

numpy.interpd -returning only the last value after interpolation

I have a set of data points in pressure(p) and vmr.
I want to find the vmr values for another pressure grid(pressure_grid).I used np.interp,
for lines in itertools.islice(input_file, i, l):
lines=lines.split()
p.append(float(lines[0]))
vmr.append(float(lines[3]))
x = np.array(p)
y = np.array(vmr)
yi=np.interp(pressure_grid,x,y)
But when I tried to print "yi" it is printing only the value(i.e.,vmr value) corresponding to the last value of "pressure_grid".For all iterations it is printing the same value
I tried to print p and vmr ,Everything seems to be fine till there.I'm not able to understand why this is happening...
I'm new to this........Please Help
This is how my file looks like,first column-p and second column-vmr.
and this is my pressure grid
https://1drv.ms/t/s!AmPNuP3pNnN8g35NPwIfzSl-VBeO
https://1drv.ms/f/s!AmPNuP3pNnN8hAx3opovgipabSjJ
There are two issues with your code. First x and y are being overwritten for each iteration of the for loop, which means, x and y contain just a single element for the interpolation. To fix this, you could define x and y list outside the loop and append in the for loop, or more simply, just use numpy.loadtxt():
import numpy as np
data = np.loadtxt('demo.txt',comments='<',usecols=[0,2])
Here, I have specified to skip rows beginning with a less than sign, so we only get the actual data.
Second, for numpy.interp to actually work, you need the x-coordinate to be an increasing sequence. (check the notes). For your data, x is a decreasing sequence, so you should flip the data after loading it:
x = data[::-1,0]
y = data[::-1,1]
interpolation = np.interp(grid,x,y)
Alternatively, you could just use the scipy.interpolate package on the original, unflipped data. This has the added advantage of allowing you to extrapolate data that isn't enclosed by your input domain:
from scipy import interpolate
interpolation = interpolate.interp1d(x,y,fill_value='extrapolate')
Note: your input file appears to have more than one <Matrix> </Matrix> set. To get all this to work, I trimmed the file so it only contained one dataset. Otherwise, your x input data will not be strictly increasing, even after flipping, and you will have to sort.

PHPExcel Protect a single column

I have issues with cell protection.
I would like to protect just one column, B for example.
So I tried:
$sheet->getProtection()->setSheet(true);
$highestRow = $sheet->getHighestRow();
$sheet->getStyle('A1:J2000)->getProtection()->setLocked( PHPExcel_Style_Protection::PROTECTION_UNPROTECTED );
for($i=1;$i<=$highestRow;$i++)
{
$sheet->getStyleByColumnAndRow(1,$i)->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
}
But it's really slow, and not good because if I need to open my sheet again
$highestRow = $sheet->getHighestRow(); will return "J".
Another solution would be to get the last non-empty column, do you know how to do that? Because getHighestRow(Column) return the columns unprotected or empty.
The loop is slow because you're applying the style to each individual cell, rather than to the range of cells demonstrated in your
$sheet->getStyle('A1:J2000)->getProtection()->setLocked( PHPExcel_Style_Protection::PROTECTION_UNPROTECTED );
line
: one call to set the style for a range of 1000 cells is more that 1000 times faster than applying it to each of 1000 cells individually.
$sheet->getHighestDataRow();
will return the highest row in the worksheet that contains actual data values
$sheet->getHighestDataColumn();
is the column equivalent
First you can protect complete sheet. After that you can uprotect others. This code will protect the first column and first
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
$objPHPExcel->getActiveSheet()->getStyle('B2:Z400')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);

MSchart label inside chart area

Can somebody please tell me how can i show the Total Collection on MSChart
You can use chart.Annotations property to get a similar result.
For example with the following code (located after filling the chart):
var ann = new RectangleAnnotation();
ann.Text = "Total Collection" + Environment.NewLine + "250 Billion";
ann.IsMultiline = true;
ann.AxisX = this.chart1.ChartAreas[0].AxisX;
ann.AxisY = this.chart1.ChartAreas[0].AxisY;
ann.AnchorX = 9; // as you can see from the image below,
ann.AnchorY = 41; // these values are inside the range
// add the annotation to the chart annotations list
this.chart1.Annotations.Add(ann);
I got the following result:
N.B.:
there are a lot of annotations types (CalloutAnnotation, EllipseAnnotation...) and they have a lot of properties to change styles and behaviors. You can even set a property to allow annotation moving (i.e. AllowMoving=true).
Have a look to annotation properties through intellisense or MSDN.
You can set the property IsDockedInsideChartArea to true. You will also need to specify which ChartArea the legend is docked to, and set the position property to Auto.
legend.IsDockedInsideChartArea = true;
legend.DockedToChartArea = "ChartArea1";
There are more information about this and other legend properties here.