I create SVG output with dot. When I set penwidth = 2 for nodes and edges, the arrowheads point slightly inside the boxes. Is there a way to avoid this? Maybe by drawing the nodes after the edges? Or by reducing the length of the edges/arrows to 95%? I've tried to find an attribute that would allow this, but could not find something that worked.
NOTE: Effect can't be seen when converting to png or jpg. Create SVG with dot -Tsvg file.dot > file.svg and view in browser.
This is my dot file:
digraph configure {
node [
shape = box,
fontname = "Courier",
style = "filled",
fillcolor = "#cccccc",
penwidth = 2
];
A [label = "configure.in"];
B [label = "autoconf\nGNU m4", fillcolor = ".7 .3 1.0"];
C [label = "configure"];
X [label = "cfg.hin", fillcolor = "#eeeeee"];
Y [label = "cfg.h", fillcolor = "#eeeeee"];
edge [
fontname = "Palatino-Italic",
fontsize = 9,
penwidth = 2,
arrowsize = 1
];
A -> B [label = " is input to"];
B -> C [label = " creates"];
subgraph cfg {
rank = same;
rankdir = LR;
X -> C [label = "is input to "];
C -> Y [label = "creates "];
}
}
Related
I want to create interactive line- and topoplot depending on menu. I figured out how to make red the line chosen in menu, but it doesn't work for topoplot marks (black circles inside topoplot). I can change it manually (cmap[][4] = RGB{N0f8}(1.0,0.0,0.0)), but how to do that interactively?
f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98), resolution = (1500, 700))
ax = Axis(f[1:3, 1], xlabel = "Time [s]", ylabel = "Voltage amplitude [µV]")
N = 1:length(pos) #1:4
hidespines!(ax, :t, :r)
GLMakie.xlims!(-0.3, 1.2)
hlines!(0, color = :gray, linewidth = 1)
vlines!(0, color = :gray, linewidth = 1)
times = range(-0.3, length=size(dat_e,2), step=1 ./ 128)
lines = Dict()
for i in N
mean_trial = mean(dat_e[i,:,:],dims=2)[:,1]
line = lines!(times, mean_trial, color = "black")
lines[i] = line
end
hidedecorations!(ax, label = false, ticks = false, ticklabels = false)
topo_axis = Axis(f[2, 2], width = 178, height = 178, aspect = DataAspect())
Makie.xlims!(low = -0.2, high = 1.2)
Makie.ylims!(low = -0.2, high = 1.2)
topoMatrix = eegHeadMatrix(pos[N], (0.5, 0.5), 0.5)
cmap = Observable(collect(ColorScheme(range(colorant"black", colorant"black", length=30))))
#cmap[][4] = RGB{N0f8}(1.0,0.0,0.0)
topo = eeg_topoplot!(topo_axis, N, # averaging all trial of 30 participants on Xth msec
raw.ch_names[1:30];
positions=pos, # produced automatically from ch_names
interpolation=NullInterpolator(),
enlarge=1,
#colorrange = (0, 1), # add the 0 for the white-first color
colormap = cmap[],
label_text=false)
hidedecorations!(current_axis())
hidespines!(current_axis())
num_prev = 0
menu = Menu(f[3, 2], options = raw.ch_names[1:30], default = nothing)#, default = "second")
on(menu.selection) do selected
if selected != nothing
num = findall(x->x==menu.selection[], raw.ch_names[1:30])[]
if num_prev != 0
lines[num_prev].color = "black"
cmap[][num] = RGB{N0f8}(1.0,0.0,0.0)
end
lines[num].color = "red"
cmap[][num] = RGB{N0f8}(1.0,0.0,0.0)
num_prev = num
end
end
notify(menu.selection)
#print(cmap[])
f
We solved this by putting this string at the end of the menu.selection section:
notify(lines)
It works, because lines() automatically creates Observable.
I am trying to make a flow to show my experimental design. I have something that works, but I would like to add another layer at the bottom-which adds a question box to each group, which should be big enough to read. An example of what I have is image 1 hoping for is in image 2. Such that group 1 has a question and answer (with arrows) and group 2 and 3 has a question and 3 answers (with arrows). Of course, the arrows should be black and in the right place-its just hard to do in word!
Does anyone know how I can do this?
Image 1
Image 2
Code:
# install.packages("DiagrammeR")
#library(DiagrammeR)
schematic <- grViz("digraph lexicon {
# node definitions with substituted label text
node [fontname = Helvetica, shape = rectangle, style=filled,color=lightgrey]
tab1 [label = '##1']
tab2 [label = '##2']
tab3 [label = '##3']
tab4 [label = '##4']
tab5 [label = '##5']
node [shape = rectangle, fillcolor=PeachPuff]
tab6 [label = '##6']
node [shape = rectangle, fillcolor=CadetBlue]
tab7 [label = '##7']
node [shape = rectangle, fillcolor=Lavender]
tab8 [label = '##8']
node [fontname = Helvetica, shape = rectangle, style=bold]
m1 [label = 'Did not agree to participate n=18']
m2 [label = 'Under 18 years n=11']
m3 [label = 'No smoke in past 3 months n=8']
m4 [label = 'Did not complete survey n=155']
# creating horizontal lines
node [shape=none, width=0, height=0, label='']
{rank=same; tab1 -> m1}
{rank=same; tab2 -> m2}
{rank=same; tab3 -> m3}
{rank=same; tab4 -> m4}
# edge definitions with the node IDs
tab1 -> tab2 -> tab3 -> tab4 -> tab5->{tab6 tab7 tab8};
}
[1]: 'Raw Data n=434'
[2]: 'Agreed to participate n=406'
[3]: 'Over 18 years n=491'
[4]: 'smoke in past 3 months=403'
[5]: 'Final sample n=238'
[6]: 'Group1 n=82'
[7]: 'Group2 n=98'
[8]: 'Group3 n=88'
")
jpeg(file = "schematic.jpg")
schematic
You can just add some more nodes
schematic <- grViz("digraph lexicon {
# node definitions with substituted label text
node [fontname = Helvetica, shape = rectangle, style=filled,color=lightgrey]
tab1 [label = '##1']
tab2 [label = '##2']
tab3 [label = '##3']
tab4 [label = '##4']
tab5 [label = '##5']
node [shape = rectangle, fillcolor=PeachPuff]
tab6 [label = '##6']
node [shape = rectangle, fillcolor=CadetBlue]
tab7 [label = '##7']
node [shape = rectangle, fillcolor=Lavender]
tab8 [label = '##8']
node [fontname = Helvetica, shape = rectangle, style=bold]
m1 [label = 'Did not agree to participate n=18']
m2 [label = 'Under 18 years n=11']
m3 [label = 'No smoke in past 3 months n=8']
m4 [label = 'Did not complete survey n=155']
# ------> NEW NODES
node [fontname = Helvetica, shape = rectangle, style=bold, width = 2.5, height = 1, ALIGN = LEFT]
q1 [label = 'Question 1 \\l\n\n']
q2 [label = 'Question 2 \\l\n\n']
q3 [label = 'Question 3 \\l\n\n']
a11 [label = 'Answer 1 \\l\n\n']
a21 [label = 'Answer 1 \\l\n\n']
a22 [label = 'Answer 2 \\l\n\n']
a23 [label = 'Answer 3 \\l\n\n']
a31 [label = 'Answer 1 \\l\n\n']
a32 [label = 'Answer 2 \\l\n\n']
a33 [label = 'Answer 3 \\l\n\n']
# creating horizontal lines
node [shape=none, width=0, height=0, label='']
{rank=same; tab1 -> m1}
{rank=same; tab2 -> m2}
{rank=same; tab3 -> m3}
{rank=same; tab4 -> m4}
# edge definitions with the node IDs
tab1 -> tab2 -> tab3 -> tab4 -> tab5->{tab6 tab7 tab8};
#--------> ATTACH NEW NODES
tab6 -> q1 -> a11
tab7 -> q2 -> a21 -> a22 -> a23
tab8 -> q3 -> a31 -> a32 -> a33
}
[1]: 'Raw Data n=434'
[2]: 'Agreed to participate n=406'
[3]: 'Over 18 years n=491'
[4]: 'smoke in past 3 months=403'
[5]: 'Final sample n=238'
[6]: 'Group1 n=82'
[7]: 'Group2 n=98'
[8]: 'Group3 n=88'
")
jpeg(file = "schematic.jpg")
schematic
I wanna convert this shape to triangles mesh using shapely in order to be used later as a 3d surface in unity3d, but the result seems is not good, because the triangles mesh cover areas outside this shape.
def get_complex_shape(nb_points = 10):
nb_shifts = 2
nb_lines = 0
shift_parameter = 2
r = 1
xy = get_points(0, 0, r, nb_points)
xy = np.array(xy)
shifts_indices = np.random.randint(0, nb_points ,nb_shifts) # choose random points
if(nb_shifts > 0):
xy[shifts_indices] = get_shifted_points(shifts_indices, nb_points, r + shift_parameter, 0, 0)
xy = np.append(xy, [xy[0]], axis = 0) # close the circle
x = xy[:,0]
y = xy[:,1]
if(nb_lines < 1): # normal circles
tck, u = interpolate.splprep([x, y], s=0)
unew = np.arange(0, 1.01, 0.01) # from 0 to 1.01 with step 0.01 [the number of points]
out = interpolate.splev(unew, tck) # a circle of 101 points
out = np.array(out).T
else: # lines and curves
out = new_add_random_lines(xy, nb_lines)
return out
enter code here
data = get_complex_shape(8)
points = MultiPoint(data)
union_points = cascaded_union(points)
triangles = triangulate(union_points)
This link is for the picture:
the blue picture is the polygon that I want to convert it to mesh of triangles, the right picture is the mesh of triangles which cover more than the inner area of the polygon. How could I cover just the inner area of the polygon?
This drives me nuts.
chart_AllData = slideref.shapes.add_chart(XL_CHART_TYPE.BAR_STACKED_100, x, y, cx, cy, chart_data)
chart = chart_AllData.chart
plot = chart.plots[0]
pointCount = 0
for answer in consolidatedAnswersList: # Looping over the answer codes
print('answer: ', answer)
catBar = plot.series[pointCount].points
for cat in catBar: # Looping over the categories (= the declarations)
fill = cat.format.fill
fill.solid()
colorString = ccpStatistics.gAnswerCodeColorDict.get(answer, 'FFFFFF')
r = int(colorString[0]+colorString[1], 16)
g = int(colorString[2]+colorString[3], 16)
b = int(colorString[4]+colorString[5], 16)
fill.fore_color.rgb = RGBColor(r , g , b)
print('setting ', answer, ' to ', colorString)
pointCount += 1
print(ccpStatistics.gAnswerCodeColorDict)
category_axis = chart.category_axis
category_axis.minor_tick_mark = XL_TICK_MARK.OUTSIDE
category_axis.tick_labels.font.italic = True
category_axis.tick_labels.font.size = Pt(12)
value_axis = chart.value_axis
value_axis.format.line.color.rgb = RGBColor(0 , 0 , 0)
value_axis.tick_labels.font.size = Pt(int(thisPageDict.get('SCALEFONTSIZE', ['18'])[0]))
value_axis.major_tick_mark = XL_TICK_MARK.OUTSIDE
value_axis.has_major_gridlines = True
value_axis.tick_labels.font.color.rgb = RGBColor(0,0,0)
value_axis.major_tick_mark.number_format = '0.0"%"'
chart.has_legend = True
chart.legend.position = XL_LEGEND_POSITION.RIGHT
chart.legend.include_in_layout = False # set to true
chart.legend.font.color.rgb = RGBColor(0,0,0)
chart.legend.font.size = Pt(int(thisPageDict.get('LEGENDSIZE', ['12'])[0]))
plot.has_data_labels = True
data_labels = plot.data_labels
data_labels.position = XL_LABEL_POSITION.CENTER
data_labels.font.size = Pt(int(thisPageDict.get('LEGENDSIZE', ['10'])[0]))
data_labels.font.color.rgb = RGBColor(0x00, 0x00, 0x00)
The content of the ccpStatistics.gAnswerCodeColorDict is as follows:
{'oaq_NoAnswer': 'DCDCDC', 'maq_NoAnswer': 'DCDCDC', 'Answer code': 'Answer code color', '1': 'FF0000', '2': 'FF6600', '3': 'FFC301', '4': '00B050', 'OK': '00B050', 'NOK': 'FF0000', 'NA': '333333', 'NEU': 'FF00FF', 'maq': '3A87AD', 'dq': '660000', 'txta': '660000', 'nq': '660000'}
Now, the graph gets properly colored according to the settings in series... And the names of the series in the legend is OK too... But the colors of the legend does not correspond to the colors in the bar.
NOTE, similar code seems to work well in other methods. I'm at wit's end now.
See the resulting ppt chart
Try setting the color at the series level rather than at the individual point level.
fill = series.format.fill
fill.solid()
fill.fore_color.rgb = RGBColor(r, g, b)
I have a simple graphiz graph that I am trying to render with dot. It is a series of self-loops on a single state:
digraph FST {
size = "8.5,11";
label = "";
rankdir=LR;
bgcolor = "transparent";
center = 1;
rank = same;
margin = 0;
orientation = Portrait;
0 [label = "0", shape = doublecircle, style = bold, fontsize = 14, color="#339933"]
0 -> 0 [label = "a", fontsize = 14];
0 -> 0 [label = "b", fontsize = 14];
0 -> 0 [label = "cd", fontsize = 14];
0 -> 0 [label = "efg", fontsize = 14];
0 -> 0 [label = "a", fontsize = 14];
0 -> 0 [label = "q", fontsize = 14];
0 -> 0 [label = "xyzabc", fontsize = 14];
}
I compile this like:
$ cat self-loop.dot | dot -Tpng > self-loop.png
The edges however, overlap the labels and looks ridiculous. Is there some way to prevent the edges from doing this? To make them flare out more?
Resulting Graph
I have had no luck scouring forums or the graphviz documentation.
Multi-loops are a pain. Using ports (https://www.graphviz.org/doc/info/attrs.html#k:portPos) helps. Bur rankdir also causes problems, so I changed it.
digraph FST {
size = "8.5,11";
label = "";
//rankdir=LR; // note the change in rankdir!!
bgcolor = "transparent";
center = 1;
rank = same;
margin = 0;
orientation = Portrait;
0 [label = "0", shape = doublecircle, style = bold, fontsize = 14, color="#339933"]
0:nw -> 0:ne [label = "a", fontsize = 14];
0:nw -> 0:ne [label = "\nb", fontsize = 14];
0:nw -> 0:ne [label = "\ncd", fontsize = 14];
0:nw -> 0:ne [label = "\nefg ", fontsize = 14];
0:nw -> 0:ne [label = " a ", fontsize = 14];
0:nw -> 0:ne [label = " q ", fontsize = 14];
0:nw -> 0:ne [label = "xyzabc", fontsize = 14];
}
Giving: