How to assign a label to go.layout.Shape(type="line"...)? - plotly-python

I produce the following figure.
The figure has a number of add_trace applied to it with go.Scatter as arguments.
A list of 4 go.layout.Shape, type="line", with fixed color attributes, is created and the figure layout is updated with that list: fig.update_layout(..., shapes=...)
The traces have labels assigned to them that we can see to the extreme right.
Is there a way to add labels to assign to the lines as well?

You would like your lines to appear in the legend of the figure (https://plot.ly/python/legend/). However, only traces can appear in the legend, not shapes which are a kind of annotation. What you could do is to create the lines using go.Scatter(..., mode='lines'), and then they would appear in the legend. You just need to give the starting and end points in go.Scatter (see https://plot.ly/python/line-and-scatter/).

Related

Blender: split object with a shape

I've got a flat object that I want to split in multiple pieces (background: I want to print it later, but the surface of my printer is not large enough). I've modeled a simple puzzle-shape:
I would like to use this shape to cut through my object, but if I use the boolean modifier, blender generates vertexes where the shape and the object intersects, but it won't cut the object since my shape got a thickness of 0:
I don't want to make my shape thicker, because otherwise it would delete something of my object...
You are able to separate the two sides of the object from each other, and then rejoin them afterwards if you need to. (This does include the use of the boolean modifier)
First, you should add the boolean modifier to the main mesh where you want it, with the 'difference' operation. Then in edit mode, as you explained before, the vertexes are created but there isn't the actual 'cut' that you were looking for.
I recreated the scenario with a plane intersecting a cube:
This is what it looks like in edit mode after having applied the boolean modifier:
Second what you can do is (after applying the boolean modifier) select the faces you want to be separated in edit mode. Then, pressing P (shortcut for separate, you can get to it by right clicking) click on 'selection' and you should have two separate objects. One of the objects will have what looks like a missing face: If you wanted two separate objects, then you just need to add a face on the object with the missing face and you can look no further. If you wanted separate parts of objects that are separate within edit mode (all together one object in object mode) then you can select the two objects and press crtl+j. Hope this helps somehwhat!
I have selected half of the cube that I want cut out (the selection does not include the face in the middle):
There are now two objects, completely seperated from each other:

Using plotArrays in Dymola to plot the data over different x-axis values

I need to draw a graph like this:
I have used plotArrays two times(1.to get curves on the left, 2.to get curves on the right) to get the curves on in two separate plot-windows.
plotArrays(x_neg,SOC_neg,legend=names,id=1);
plotArrays(x_pos,SOC_pos,legend=names,id=2);
The middle region is empty. If I use single plotArrays function combining these data, the ends will automatically connect with each other which I don't want to do.
How can I plot it in single command?
Thank you
Use multiple calls to the function plotArray with the same id and erase=false.

qwt: how to add extra text in legend

I have a QwtPlot with a couple of lines in it. It also has a legend.
Now apart from the description of the lines themself, I would like to add extra text describing the graph in general.
E.g. "line a: length of frog, line b: weight of frog" and then as an extra "outside temperature is 12C" (the temperature is then not drawn).
The description of QwtPlot shown in legend is QwtLegendData. Further in the QwtPlotItem doc (which is a superclass of all QwtPlots):
QwtLegendData is basically a list of QVariants that makes it possible to overload and reimplement legendData() to return almost any type of information, that is understood by the receiver that acts as the legend.
So everything that you need is to pull the existing "automated" legend from the plot and add one more QwtLegendData to it. It also needs a QVariant as a "key" to distinguish between Datas for each plot, but it can be really anything expectably different from the keys of real plots. Even default (empty) QVariant() will do, if you don't plan to add any more such extra texts.
QwtLegendData data;
data.setValue(QwtLegendData::Role::TitleRole, QVariant("Outside temperature is 12C"));
QList<QwtLegendData> list;
list << data;
QwtAbstractLegend* existingLegend = frogPlot.legend();
// "update" with a new key really means "insert"
existingLegend->updateLegend(QVariant("Temperature comment extra text"), list);

How to change the range of my x-axis in matplotlib

I am trying to plot a list of 30.000 values. The name of the list is "velocity_x". I just plot them with the following command:
plot(velocity_x,'r')
the result is shown in the image below (do not pay attention to the dashed line)
Since I am using that command line, it creates automatically a x-axis of length 30.000. What I would like to do is changing the range of my x-axis in such a way to show the time(s) instead of the iterations where t = 0.0002 * iteration.
You could use linspace:
a=np.linspace(0,6,len(velocity_x))
plot(a, velocity_x, 'r' )
You can set the values by setting 'Xticklabel' see here.
You want to do something like
h=gca; %get current axis if you dont have it as a handle already.
set(h, 'Xticklabel', 0:5000*0.0002:5000*0.0002*7); %set correct ticks.
You could also try something along the lines of
plot( [i*0.0002 for i in range(len(velocity_x))], velocity_x, 'r' )

How to customize marker/symbol properties in matplotlib?

Example command:
prop = matplotlib.pyplot.scatter(x,y,s=s,c=c)
dir(prop) shows set_edgecolor, set_edgecolors, set_linestyle, set_linestyles - why so many variations on the same thing?
Also, how do I remove the edgecolors? Setting values to None does nothing. And how do I change the marker size after the plotting? There does not appear to be a markersize attribute that I can access...
Edit
If the symbols are generated through plyplot.plot, there is a markersize attribute to change it seems. But with pyplot.scatter, not present.
It'd give using 'none' a go to see if that solves your issue with edgecolor. That typically sets attributes to no color.