How to avoid x axis changed when add marks? - wpf

I have a problem to consult,when I use the Line of the Point style and show the marks, the x axis would have a problem.When annotate the code (lineSeries5.Add(5, 1,"ghgh");),the x axis shows normally like number 1,2.....,but when I use this code (lineSeries5.Add(5, 1,"ghgh"); ), the x axis becomes 'ghgh',I wonder if how to solve this problem. My purpose is showing the contents which I want to shows in the marks,but the x axis should not be changed. Waiting for your help, thank you very much!
private Steema.TeeChart.WPF.Styles.Points lineSeries5;
this.lineSeries5 = new Steema.TeeChart.WPF.Styles.Points();
this.tChart1.Series.Add(this.lineSeries5);
lineSeries5.Marks.Visible = true;
lineSeries5.Marks.Transparent = true;
lineSeries5.Pointer.Style = Steema.TeeChart.WPF.Styles.PointerStyles.Nothing;
**lineSeries5.Add(5, 1,"ghgh");**
lineSeries5.Add(9, 3);

If you want in your axis labels are values instead of labelsText, you must change the Axis labels style as I do in next line:
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;
Could you tell us if previous code solve your problem?
Thanks,

Related

I was working on this project for real time face mask detection, but the i am facing an error cannot reshape array of size 2 into shape (1,100,100,1)

Please tell me so as to what should i do to solve this problem or what values should i put to solve this problem
while(True):
ret,img = source.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces=face_clsfr.detectMultiScale(gray,1.3,5)
for x,y,w,h in faces:
face_img = gray[y:y+w,x:x+w]
resized = cv2.resize(face_img,(100,100))
normalized=resized/255,0
reshaped = np.reshape(normalized, (1,100,100,1))
result=model.predict(reshaped)
label=np.argmax(result,axis=1)[0]
cv2.rectangle(img,(x,y),(x+w,y+h), colordict[label],2)
cv2.rectangle(img,(x,y-40),(x+w,y), colordict[label],-1)
cv2.putText(img,labels_dict[label], (x,y-10), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)
cv2.imshow('Frame',img)
key=cv2.waitKey(1)
if(key=='q'):
break
cv2.destroyAllWindows()
source.release
You change the array type of image to a tuple in:
normalized = resized/255,0
change to:
normalized = resized/255

multiple matplotlib chart using loop

I need to draw multiple matploblib chart using a for loop.
I have a data from with multiple column of data points and a time series 'year'. I need to create chart for each column.
I have the following code:
df=pd.DataFrame({'Time':['2014','2015','2016','2017','2018','2019'],
'A':[1,8,3,10,5,6],
'B':[2,3,5,2,3,5],
'C':[7,4,12,11,8,1],
'D':[3,4,2,2,7,7]})
x_pos=range(len(df['Time']))
m,c = np.polyfit(x_pos,df['A'],1)
plt.scatter(x=x_pos,y='A',data=df)
plt.plot(x_pos,m*x_pos+c,'--r')
any help is appreciated
I was able to figure it out. I used the matplotlib.gridspec to achieve this.
Following is the solution:
df=pd.DataFrame({'Time':['2014','2015','2016','2017','2018','2019'],
'A':[1,8,3,10,5,6],
'B':[2,3,5,2,3,5],
'C':[7,4,12,11,8,1],
'D':[3,4,2,2,7,7]})
#import gridspec to fit subplots
import matplotlib.gridspec as gridspec
fig = plt.figure(figsize=(10,10))
# set grid size 2*2
ggpec = gridspec.GridSpec(2, 2)
getaxs = []
datacolumns = list(df[['A','B','C','D']])
for i,j in zip(datacolumns,range(1,len(datacolumns)+1)):
xpos=range(len(df['Time']))
getaxs.append(fig.add_subplot(ggpec[j - 1]))
m,c = np.polyfit(x_pos,df['A'],1)
getaxs[-1].scatter(x=xpos,y=i,data=df)
getaxs[-1].plot(x_pos,m*x_pos+c,'--r')
plt.show()
The final result will be something like following:

Store formatting information in an array then apply it to a range

I'm trying to create a script that will automatically format a selection based on the formatting of a table in another sheet. The idea is that a user can define a table style for header, rowOdd and rowEven in the Formats sheet, then easily apply it to a selected table using the script.
I've managed to get it working, but only by applying one type of formatting (background colour).
I based my code for reading the code into an array on this article.
As you will hopefully see from my code below, I am only able to read one formatting property into my array.
What I would like to do is read all formatting properties into the array, then apply them to the range in one go. I'm new to this so sorry if my code is a mess!
function formatTable() {
var activeRange = SpreadsheetApp.getActiveSpreadsheet().getActiveRange(); //range to apply formatting to
var arr = new Array(activeRange.getNumRows());
var tableStyleSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Formats"); //location of source styles
var tableColours = {
header: tableStyleSheet.getRange(1, 1, 1).getBackground(),
rowEven: tableStyleSheet.getRange(2, 1, 1).getBackground(),
rowOdd: tableStyleSheet.getRange(3, 1, 1).getBackground()
}
for (var x = 0; x < activeRange.getNumRows(); x++) {
arr[x] = new Array(activeRange.getNumColumns());
for (var y = 0; y < activeRange.getNumColumns(); y++) {
x == 0 ? arr[x][y] = tableColours.header :
x % 2 < 1 ? arr[x][y] = tableColours.rowOdd : arr[x][y] = tableColours.rowEven;
Logger.log(arr);
}
}
activeRange.setBackgrounds(arr);
}
Thanks!
I might be wrong but based from the list of methods given in Class Range, feature to save or store formatting details currently do not exist yet.
However, you may want to try using the following:
copyFormatToRange(gridId, column, columnEnd, row, rowEnd) or copyFormatToRange(sheet, column, columnEnd, row, rowEnd) wherein it copies the formatting of the range to the given location.
moveTo(target) wherein it cuts and paste (both format and values) from this range to the target range.
Did you know that you can get all of the different formatting elements for a range straight into an array?
E.g.
var backgrounds = sheet.getRange("A1:D50").getBackgrounds();
var fonts = sheet.getRange("A1:D50").getFontFamilies();
var fontcolors = sheet.getRange("A1:D50").getFontColors();
etc.
However, there's no way to get all of the formatting in one call unfortunately, so you have to handle each element separately. Then you can apply all of the formats in one go:
targetRng.setFontColors(fontcolors);
targetRng.setBackgrounds(backgrounds);
and so on.

line graph Tickmarks and grid vertical lines are not aligned?

Okay. i have this problem in line graph. Tickmarks(data-points) are not aligned with vertical grid lines. is there a way to achieve that.please help?
you number of tick marks need to match the number of vlines. What I often do is I will get the count of my labels variable (with javascript) and so something like this.
var numTicks = labelVariable.length;
Then on draw of the graph
options: {
numxticks: num_ticks
}
var xticks = 10;
or with php
var xticks = "<php echo $yourvariable ;?>";
var line = .......
.set('chart.numxticks',xticks)

VirtualEarth: determine min/max visible latitude/longitude

Is there an easy way to determine the maximum and minimum visible latitude and longitude in a VirtualEarth map?
Given that it's not a flat surface (VE uses Mercator projection it looks like) I can see the math getting fairly complicated, I figured somebody may know of a snippet to accomplish this.
Found it! VEMap.GetMapView() returns the bounding rectangle, even works for 3D mode as well (where the boundary is not even a rectangle).
var view = map.GetMapView();
latMin = view.BottomRightLatLong.Latitude;
lonMin = view.TopLeftLatLong.Longitude;
latMax = view.TopLeftLatLong.Latitude;
lonMax = view.BottomRightLatLong.Longitude;
Using the Virtual Earth Interactive SDK, you can see how to convert a pixel point to a LatLong object:
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
}
function DoPixelToLL(x, y)
{
var ll = map.PixelToLatLong(new VEPixel(x, y)).toString()
alert("The latitude,longitude of the pixel at (" + x + "," + y + ") is: " + ll)
}
Take a further look here: http://dev.live.com/virtualearth/sdk/ in the menu go to: Get map info --> Convert pixel to LatLong
To get the Max/Min visible LatLong's, you could call the DoPixelToLL method for each corner of the map.

Resources