How can I change the caption for the Heatmap as the method takes no arguments? - seaborn

I plotted a graph and would like to change the title but I don't see any parameter for this:
code:
klib.corr_plot(df)
I need to change the caption which is fixed at 'Feature-correlation (pearson)'

Catch the axes object and use the set_title method:
ax = klib.corr_plot(df)
ax.set_title('new title')

Related

How do I change the color of already drawn InkStrokes in windows universal

I have drawn some ink strokes on an InkCanvas and am now wanting to change the pen colour. I can change the colour of any additional strokes I draw using CopyDefaultDrawingAttributes and UpdateDefaultDrawingAttributes and that works fine. But how do I alter the color of the strokes that are already present StrokeContainer? I've tried:
foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes())
{
stroke.DrawingAttributes.Color = strokeColour;
};
This code executes with no exceptions, but stroke.DrawingAttributes.Color still shows the previous colour.
Any ideas?
Thanks...
Robert
You cannot set the DrawingAttributes property of the stroke directly. You must create a copy of the InkDrawingAttributes of the stroke, set the desired values for that InkDrawingAttributes object, and then assign the new InkDrawingAttributes to the DrawingAttributes of the stroke.
So you can code for example like this:
foreach (InkStroke stroke in inkCanvas.InkPresenter.StrokeContainer.GetStrokes())
{
//stroke.DrawingAttributes.Color = Windows.UI.Colors.Yellow;
InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
drawingAttributes.Color = Windows.UI.Colors.Yellow;
stroke.DrawingAttributes = drawingAttributes;
}
For more information, you can refer to InkStroke.DrawingAttributes | drawingAttributes property.

Changing colors on dimple.js scatter plot

How can I change the color of the circles on a scatter plot based on one of the fields that I'm not using on neither of the axes?
Example, this code:
var myChart3 = new dimple.chart(svg3, data);
myChart3.addMeasureAxis("x", "salary");
myChart3.addMeasureAxis("y", "bonus");
var mySeries = myChart3.addSeries(["Index","a"], dimple.plot.scatter);
myChart3.draw();
produces this graph:
but I also would like to color the bubbles based on a third field called "department"
thanks
The first parameter of addSeries determines colours. In the case of an array the last element is used, so you just need to do:
var mySeries = myChart3.addSeries(["Index","a","department"], dimple.plot.scatter);

Cursor position over an image in MATLAB

I have an image opened in an axes object inside a GUIDE MATLAB GUI. I want to be able to update some variables depending in the position of the cursor over the image. My effort in order to achieve it has been to use the following code to set the behavior of the axes:
pointerBehavior.enterFcn = [];
pointerBehavior.exitFcn = [];
pointerBehavior.traverseFcn = #(figHandle, currentPoint)CoordChanger(figHandle,currentPoint, hObject, handles);
iptSetPointerBehavior(handles.axes1, pointerBehavior);
iptPointerManager(gcf);
With the following function:
function CoordChanger(figh, cp, hObject, handles)
handles.output = hObject;
CursorPosition = get(handles.axes1,'CurrentPoint')
guidata(hObject, handles);
However when I look at the CursorPosition value while I’m moving the cursor along the image it always shows the same value. What am I doing wrong? Is there any other way to achieve the same result?
Look at the cp variable inside CoordChanger, you should see the cursor position changing there.

Select a line in a d3.js or nvd3.js line graph

In a D3 or NVD3.js line graph, how can I select a particular line once the graph is rendered? For example, suppose I want to animate the stroke width on a line, like this:
d3.selectAll('path').transition().duration(2000).style("stroke-width", "20");
The above will select all paths, obviously, but I would like to select a particular series—for example, the Oranges series in a data set defined like this:
var data = [{key: "Apples", values: array1},{key: "Oranges", values: array2}]
I thought something this might work, but it did not:
d3.select('#chart svg').datum(data[1]).transition... // or alternatively,
d3.select('#chart svg').datum(data[1].values).transition...
I've been trying to figure it out using the Cumulative Line Chart example in the code editor here, with no success: http://nvd3.org/livecode/#codemirrorNav
This is a very basic question, but I'm new to D3 and have been unable to figure it out.
There are couple of simple ways that I can think of:
You can store each path in its own variable (or inside an array):
var path1 = graph.append("g").append("path").data([data1]).attr("class", "line1");
Now you can apply your transitions to just this path variable and it should work.
Another option is to give each path a unique class and then use d3.selectAll(".uniqueclassname") and apply your transitions.
In this fiddle, look at the tick function (specially for the following piece of code).
// redraw the lines
graph.select(".line1").attr("d", line).attr("transform", null);
path2.attr("d", line).attr("transform", null);
path3.attr("d", line).attr("transform", null);
graph.select(".line4").attr("d", line).attr("transform", null);

Discrete Bar Chart colors nvd3.js

I am using nvd3.js discrete bar http://nvd3.org/ghpages/discreteBar.html
I am inspecting the code and seen that the color is been derived inline
style="fill: #ffbb78; stroke: #ffbb78;"
I also track on the discreteBarChart function
color = nv.utils.getColor()
What I don't realizing and asking is what does color takes as a parameter ?
It requires and array of colors => ['#aec7e8', '#7b94b5', '#486192'] , something like this would work.
var chart = nv.models.discreteBarChart()
....
....
.color(['#aec7e8', '#7b94b5', '#486192']);
NVD3 inherits the defaults colurs set by d3 here
Hope it helps.
If you want to use one single colour, then it can be returned from the options object like below :
var options={
....
colour:function(){
return '#ff0000';
},
...
..
}

Resources