How to add an annotation outside of a node in Graphviz' dot? - eclipse

I am very new to Dot and trying to visualize a callgraph with Dot and Zest in Eclipse. And I would like to annotate nodes with kind of annotation (OK and Failed on the pic.).
Is there any common way to do this for Dot or Zest?

xlabel
Have a look at xlabel (external label).
main.dot
graph {
node [shape=square];
1 [xlabel="a"]
2 [xlabel="b"]
1 -- 2;
}
Convert:
dot -Tpng main.dot > main.png
Output:
Not sure however how easily you can control exact label placement with this method: even overlaps can happen by default. See:
Graphviz graph positioning xlabels
xlabels for nodes overlap with edges in dot
shape=record
I just tend to prefer the shape=record approach mentioned by https://stackoverflow.com/a/23031506/895245 or their generalization, HTML-like labels, as it makes it clearer what label belongs to each node:
graph {
rankdir=LR
node [shape=record];
1 [label="1|a"]
2 [label="2|b"]
1 -- 2;
}
Output:
TODO can you avoid typing 1 and 2 twice?
Tested on Ubuntu 16.10, graphviz 2.38.

It's not supported by the Zest rendering, but on the DOT level you could use record-based nodes:
rankdir=LR;
node [shape=record];
m1[label="void m1()|OK"];
m1[label="void m2()|Failed"];
For details see http://www.graphviz.org/doc/info/shapes.html#record

Related

Vega-Lite - Error in the scales of circles and lines

I'm trying to use Vega-Lite to do a plot similar to a graph, where nodes are connected to other nodes by edges. The nodes vary in size according to a variable,while the edges width also vary.
The information for the nodes is stored in a different dataset than the information for the edges.
The problem is, once I try to plot everything together ("nodes" + "edges"), Vega-Lite is marking the size of the nodes very small (almost not visible). If I don't use the "size" for my edges plot, everything comes out normal.
Here is an example of what I'm doing (note that the notation is a bit different from native Vega-Lite, because I'm programming on Julia):
v1 = #vlplot(
mark={:circle,opacity=1},
x={μ[:,1],type="quantitative",axis=nothing},
y={μ[:,2],type="quantitative",axis=nothing},
width=600,
height=400,
size={μ_n,legend=nothing,type="q"})
v2 = #vlplot(
mark={"type"=:circle,color="red",opacity=1},
x={ν[:,1],type="quantitative",axis=nothing},
y={ν[:,2],type="quantitative",axis=nothing},
width=600,
height=400,
size={ν_m,legend=nothing,type="q"})
Then, when I create the visualization for the edges, and plot everything together:
v3 = #vlplot(
mark={"type"=:line,color="black",clip=false},
data = df,
encoding={
x={"edges_x:q",axis=nothing},
y={"edges_y:q",axis=nothing},
opacity={"ew:q",legend=nothing},
size={"ew:q",scale={range=[0,2]},legend=nothing},
detail={"pe:o"}},
width=600,
height=400
)
#vlplot(view={stroke=nothing})+v3+v2+v1
Any ideas on why this is happening and how to fix it?
(Note that the "scale" attribute is not the reason. Even if I remove it, the problem persists).
When rendering compound charts, Vega-Lite uses shared scales by default (see https://vega.github.io/vega-lite/docs/resolve.html): it looks like when your size scale is shared between the line and circle plots, it leads to poor results.
I'm not familiar with the VegaLite.jl syntax, but the JSON specification you'll want on the top-level chart is:
"resolve": {"scale": {"size": "independent"}}

Color nodes in Networkx Graph based on specific values

I have looked a bit into the node_color keyword parameter of the nx.draw() method. Here are two different graphs colored using node_colors.
node_colors = [.5,.5,0.,1.]. Colors appear as expected
node_colors = [.9,1.,1.,1.]. Colors do not appear as expected
In the second image, I would expect the color of node 1 to be almost as dark. I assume what is happening is the colormap is getting scaled from the minimum value to the maximum value. For the first example, that's fine, but how can I set the colormap to be scaled from: 0=white, 1=blue every time?
You are correct about the cause of the problem. To fix it, you need to define vmin and vmax.
I believe
nx.draw(G, node_color=[0.9,1.,1.,1.], vmin=0, vmax=1)
will do what you're after (I would need to know what colormap you're using to be sure).
For edges, there are similar parameters: edge_vmin and edge_vmax.

Swift charts framework - mark/highlight regions of LineChart?

I am wondering if anyone knows of an elegant way to mark and highlight parts of a LineChart.
This could be done in a variety of ways, for example:
A. Using a dashed line "marked" regions of the graph
B. Shading the region underneath "marked" regions of the graph
ex: Filled Area Example
C. Using two distinct markers to distinguish the beginning and end of a "marked" region of the graph
The process of "marking" does not have to be touch-based - programmatic is OK too.
Any suggestions on implementation would be appreciated...thanks!

Some way to outline labeled regions separately?

I have processed an image to the point where I have certain labelled regions. Shown here with each labelled region in different shade.
I would like to show the outline of each region separately. Currently I am using bwmorph(labeledImage,'remove') but this treats any regions contacting each other and keeps the outlines of the conjunction of the multiple regions.
I am looking for a function that will keep all the outline / edge pixels for each region, something that would result in an image like the following (green edges added to show what is missing from the method I am already using).
You can differentiate all regions, so why dont you treat them separatly?
See this bwboundaries.

produce several maps in same figure window in matlab

I would like to generate a figure in matlab which looks like the attached .jpeg:
So, the figure should contain an outline of the world and then 3 other figures looking at the USA, UK, and New Zealand where I can then specify individual locations in each country. How would I achieve this?
Subplots to arrange things, images to create the maps, and lines to connect them to points. To create a complicated subplot structure like that I'd suggest you check out Ben Mitch's panel class. The relevant thing you're looking for is its ability to conveniently divide up and manage subplots. Something like this
p = panel('defer');
p.pack('v', [1/5 3/5 1/5]);
p(1).pack('h',[1/5 2/5 2/5]); % top level, US and New Zealand
p(2).pack('h',[1/5 2/5 2/5]); % mid level
p(3).pack('h',[1/5 3/5 1/5]); % bottom level
p(2,2).select();
image(world_image);
p(1,3).select();
image(new_zealand_image);
p(1,3).select();
image(usa_image);
p(1,1).select();
image(uk_iamge);
Then add a few line commands to show where the submaps link to. Note that I haven't gotten a chance to test the above code yet, but will when I get to work. I can't remember offhand if it likes the 'h' argument within the child panels.