I have generated an Excel chart using Qtxlsx ,and i want to invert the axes from (Left/buttom) to (right/top) but i can't find the functions to change there positions.
Here is the code
Chart *lineChart = xlsx.insertChart(23,3, QSize(600, 400));
lineChart->setChartType(Chart::CT_Line);
lineChart->addSeries(CellRange("A4:A9"));
Related
I'm using the Qt C++ ArcGIS Runtime SDK v100.9 and I have various shapes and labels being drawn on a map.
I want to be able to find out the area (bounding rectangle) of Graphic (which is a text label (TextSymbol) at a given point (SpatialReference::wgs84) on the map) so I can determine if the width of the label is more or less than another Graphic (lets say it has a Polygon for its Geometry which is being used to draw a circle) in order to decide if the label should be set to visible or not.
Within a class derived from Esri::ArcGISRuntime::MapGraphicsView the circle and the text label are created along the lines of:
Point centerWgs84(0.0, 0.0, SpatialReference::wgs84());
Graphic* circleGraphic_p = new Graphic(GeometryEngine::bufferGeodetic(centerWgs84, 1000.0, LinearUnit::meters(), 0.5, GeodeticCurveType::Geodesic));
this->graphicsOverlays()->at(0)->graphics()->append(circleGraphic_p);
circleGraphic_p->setSymbol(new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor(Qt::blue), 1.0));
circleGraphic_p->setVisible(true);
TextSymbol* textMarker_p = new TextSymbol("Some Label", Qt::black, 12.0, HorizontalAlignment::Center, VerticalAlignment::Bottom);
Graphic* labelGraphic_p = new Graphic(centerWgs84, textMarker_p);
this->graphicsOverlays()->at(0)->graphics()->append(labelGraphic_p);
labelGraphic_p->setVisible(true);
Rather than always setting the label visibility to true, I thought I would be able to take the Geometry of each Graphic and use it to construct an Envelope which would allow me to then get the width of each envelope that could then be compared:
Envelope circleEnvelope(circleGraphic_p->geometry());
Envelope labelEnvelope(labelGraphic_p->geometry());
labelGraphic_p->setVisible(circleEnvelope.width() >= labelEnvelope.width());
but when I try and do this, the width of each envelope is always a very small negative value (such as -2.25017... e-98)
Any suggestions on what I am doing wrong or if there is a better way to get the size on the map (or in device independent units) of the text label and a Graphic described by the Geometry of a Polyline or Polygon?
EDIT: I've discovered that the Geometry object has an extent() method from which I can get the width of the circle but the Geometry of the Graphic being used for the text label results in a width of zero from its extent() method. I expect this is because the Geometry is just a Point which has no width or height. So the question still stands of how to get the bounding rectangle of a TextSymbol?
You are correct, the extent is being returned of the underlying geometry, not the TextSymbol. I don't think you will be able to achieve what you are wanting in the way you are going about it, as there isn't a way to get the bounding box or screen coordinates of the symbol itself. Instead, have you considered using LabelDefinitions and setting the various deconfliction options? This sample shows labels on layers, but can be applied to graphics as well. There are many labeling options you can apply, and this would allow the internal labeling engine to deconflict for you.
Is it possible for me to supply a chart.js chart with a list of Y values that have a corresponding label/X value and place them vertically and horizontally relative to their own value.
For example: I have a list of values at a certain time (unix timestamp) that I want to show on a chart, with its Y value positioned relative, but also its horizontal position and its label relative on the x-scale.
At this moment it always spaces out my labels, completely over the entire x axis, at equal distances, without taking into account the values of the labels itself. Is there way to automatically accomplish this with chart.js ?
A line or scatter chart will do the job. The main criteria is that the data is a series of x and y coordinates. Each point in the array is in the form:
{
x: xValue,
y: yValue
}
See http://www.chartjs.org/samples/latest/charts/scatter/basic.html
here is a jsfiddle that reproduces your image.
I am generating a URL that needs to create a PNG Graph, using Google Charts API.
I thought that I had all the parameters in the right position however the graph is not displaying correctly? It is only displaying one of the series, and even then, the series data is wrong.
If anyone can point me in the right direction, it would be much appreciated!
http://chart.apis.google.com/chart?
cht=lc&chs=800x350& // CHART SIZE
chco=6a6572,6a6572,6a6572,6a6572& // SERIES COLOURS
chxr=1,-11519.670000,19297.010000& // Y AXIS RANGE
chxt=x,y& // X & Y AXIS
chxl=0:|January%2017|February%2017|March%2017|April%2017|May%2017& // X AXIS VALUES
chdl=A|B|C|D& // SERIES NAMES
chtt=Sales+Year+To+DateYYYY& // CHART TITLE
chts=000000,24& // CHART COLOR AND FONT SIZE
chd=t:6032,13921,0,1263,19297|-1330,-11520,-4410,490,-361|298,798,285,228,108|884,1651,1161,1473,961
// SERIES VALUES
I finally figured it out. For some reason the series values parameters were taking a percentage value? So once I converted the values to a percentage of the total, it displayed fine.
I'm having trouble creating a colorbar for my plot in Python using matplotlib. I am using a colormap, not to colour all the data that I plot but to extract a colour for a plot based on a value I'm not plotting. Hope this makes sense..
So I'm in a for loop, create a plot every time with a colour based on a certain parameter. Like this (the data is an example to create an mwe, my data is more complicated):
import matplotlib as mpl
from matplotlib import pyplot as plt
import numpy as np
xdata = np.array(range(10))
parameter = [0.5, 0.3, 0.78, 0.21, 0.45] #random parameter example
cmap = mpl.cm.get_cmap('jet')
for i in range(len(parameter)):
clr = cmap(parameter(i))
plt.plot(xdata,xdata**i,c=clr)
plt.show()
Now, what I would want is a colorbar on the side (or actually two, but that's another problem I think) that shows the jet colormap and according values. The values need to be scaled to a new min and max value.
So far I've found the following, but I don't understand it enough to apply it to my own problem:
Getting individual colors from a color map in matplotlib
Which told me how to extract the colour and shows how to create the normalized colormap
Colorbar only
Which should tell me how to add a colorbar without using the plotted data, but I don't understand enough of it. My problem is with the creation of the axes. I don't understand this part if I want to put the colorbar next to my plot. In the example they create a figure with handle fig, but in my case the figure is created when I do plt.imshow(image), since this is what I start with and then I'm plotting over the image. I cannot use the fig.add_axes here.
I hope you can help me out here. It would be great if I could also create a 'reversed' colorbar. So either the colours are in reverse direction, or the values next to the bar.
At any point in the script you can get the figure via fig = plt.gcf() and an axes via ax=plt.gca(). So, adding an axes may be done by plt.gcf().add_axes(...).
There is also nothing wrong with putting fig=plt.figure() before plotting anything.
Note that after creating a new axes, plt.gca() will return the new axes, so it is a good idea to create a reference to the main axes before adding a new one.
A convenient way to obtain a figure and an axes for later referencing is to create the figure via
fig, ax = plt.subplots()
Colormaps:
Every standard colormap has a reversed version, which has _r at the end of its name, e.g. you can use viridis_r instead of viridis.
I have got an image in opencv, and I want to add labels in the axis. Actually I want similar implementation as xlabel and ylabel matlab functions. How is it then, to add labels in both x and y axis of an image?
If you have a string a label variable label image matrix img and positions x and y , you can do
putText(img, label, Point(x, y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
The additional parameters are for font attributes.
You will need to get the size of the original image and then create a new image that is larger than the existing image from this, manually draw your Axis in this image, and label them using the putText function. Then insert the original image into the relevant portion of this new image.
Images dont have "Axis" as such, so your labels and axis will need to be part of the image!