Created
June 4, 2020 15:01
-
-
Save pallada-92/8b91968728e625cdeebc60570835891c to your computer and use it in GitHub Desktop.
Wordcloud example v0.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
terms_sizes = [] | |
terms_labels = [] | |
terms_colors = [] | |
random.seed(0) | |
for i in range(200): | |
terms_sizes.append(random.random()) | |
# terms_labels.append(''.join(random.choices(['abcdefgh ', 'cdefg ', 'gh '], k=random.randint(1, 2))).strip()) | |
terms_labels.append(demo_data['label'][i]) | |
terms_colors.append(random.random()) | |
spec = { | |
"layers": [{ | |
"type": "bg", | |
"fill": "white" | |
}, { | |
"enabled": True, | |
"name": "central_term", | |
"type": "text", | |
"text": 'DATA\nVISUALIZATION', | |
"size": 50, | |
"fill": 'black', | |
'font': 'Calibri[bold]', | |
"x": 0, | |
"y": 0 | |
}, { | |
'name': 'term', | |
'type': 'text', | |
'fill': terms_colors, | |
'size': terms_sizes, | |
'text': terms_labels, | |
'x': 0, | |
'y': 0, | |
}, { | |
"name": "vis_copyright", | |
"type": "text", | |
"text": 'Источник: система интеллектуального анализа больших данных iFORA', | |
"text_fill_gradient_darker_coeff": 1.2, | |
"text_fill": "black", | |
"font": f"Calibri[italic]", | |
"font_size": 22, | |
"align": "right", | |
"valign": "baseline", | |
"x": 0, | |
"y": 0, | |
}, { | |
"name": "vis_title", | |
"text": 'Облако слов направлений визуализаций', | |
"type": "text", | |
"text_fill_gradient_darker_coeff": 1.2, | |
"text_fill": "black", | |
"font": "Calibri", | |
"font_size": 50, | |
"align": "center", | |
"valign": "baseline", | |
"x": 0, | |
"y": 0, | |
}], | |
"operations": [{ | |
"enabled": True, | |
"type": "color_scale", | |
"cmap": "ifora_rainbow", | |
"null_color": "gray", | |
"value_field": 'term/fill', | |
"color_field": 'term/fill', | |
"mode": "rank", | |
"stop0": 0.4, | |
"stop1": 1.0, | |
"min_lightness": 50, | |
"max_lightness": 50, | |
}, { | |
'enabled': 1, | |
'type': 'transform_text', | |
'add_spaces': True, | |
'newlines': None, | |
}, { | |
"enabled": 1, | |
"name": "set_viewbox", | |
"type": "set_viewbox", | |
"cx": 0, | |
"cy": 0, | |
"size": 1000, | |
"ratio": 1, | |
}, { | |
'type': 'normalize', | |
'field': 'term/size', | |
'mode': 'rank', | |
'out_min': 10, | |
'out_max': 30, | |
'gamma': 3, | |
}, { | |
"enabled": True, | |
"type": "area_correction", | |
"name": "area_correction", | |
"shape_field": ["term/shape", "central_term/shape"], | |
"size_field": ["term/size", "central_term/size"], | |
"density": 2, | |
}, { | |
'type': 'transform_shape', | |
'shape_field': 'term/shape', | |
'rpad': [3, 0], | |
}, { | |
'type': 'collide', | |
'max_shift': 1000, | |
'trials': 300, | |
'layers': ['central_term', 'term'], | |
'order': 'size[layer]', | |
'shift_shape': 'circ[smooth]', | |
}, { | |
'enabled': True, | |
'type': 'fit_viewbox', | |
}, { | |
"name": "standard_template", | |
"type": "standard_template", | |
"title_enabled": 1, | |
"copyright_enabled": 1, | |
"logo_enabled": 1, | |
"logo_image": 'ifora_logo', | |
"logo_height": "5%", | |
"title_font_size": "4%", | |
"title_margin": "3%", | |
"copyright_font_size": "2%", | |
"copyright_margin": "3%", | |
}] | |
} | |
save_dir = './200424_grid' | |
theme = 'light' | |
render_fname, save_as = [ | |
('500px.high.png', f'{save_dir}/render.{theme}.png'), | |
('high.svg', f'{save_dir}/render.{theme}.svg'), | |
('debug.svg', f'{save_dir}/debug.svg'), | |
('preset.json', f'{save_dir}/preset.json'), | |
('spec.json', f'{save_dir}/spec.json'), | |
('render.json', f'{save_dir}/render.json'), | |
][0] | |
run_semantic_map_spec('/run', spec, render_fname, save_as, overwrite=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment