This repo stores some python scripts for drawing figures in scientific papers, i.e., "Microblog Hashtag Generation via Encoding Conversation Contexts " and "Topic-Aware Neural Keyphrase Generation for Social Media Language".
Here I do not intend to give detailed tutorials on how to draw figures using python, but just share some examples, including heatmap, histogram with error bar, and line figure. This repo will be kept updating hopefully:)
- Python 3.6
- matplotlib
- pickle
- numpy
Heatmap is a kind of common figures for visualizing attention scores. There are three inputs for drawing one heatmap, including column labels, row labels, and the weights to decide the darkness of color in each grid.
Here I give two examples below: (plotted by heatmap.py
and double_heatmap.py
respectively)
As the attention weights may be in large size, you can dump it in the format of csv (e.g., bi_attn.csv
) and read it as input in the program heatmap.py
later.
Histogram with error bar is a very good choice for demonstrating your model performance. Here I give two examples: (plotted by hist_error_bar.py
and frequency_hist.py
respectively). Acknowledge Wang Chen for his help.
The error bar is computed by the standard deviation of your multiple model evaluation results. It is fed into the yerr
argument of the method matplotlib.pyplot.bar()
.
Here I show two examples on line figures: (plotted by dist_line.py
and absent_rate_lines.py
respectively)
You can first prepare the data statistics in the a collections
python object and dump them as pickle object, e.g., tw_seg_data.pickle
and wb_seg_data.pickle
. dist_line.py
reads these pickle data as input and compute its distribution for each bin.