r"""Save the plot to a file, or display it interactively. Parameters ---------- vizlib : str The visualization library: ``'matplotlib'``, ``'seaborn'``, or ``'bokeh'``. plot : module Plotting context, e.g., ``plt``. plot_type : str Type of plot to
(vizlib, plot, plot_type, tag, directory=None)
| 209 | # |
| 210 | |
| 211 | def write_plot(vizlib, plot, plot_type, tag, directory=None): |
| 212 | r"""Save the plot to a file, or display it interactively. |
| 213 | |
| 214 | Parameters |
| 215 | ---------- |
| 216 | vizlib : str |
| 217 | The visualization library: ``'matplotlib'``, ``'seaborn'``, |
| 218 | or ``'bokeh'``. |
| 219 | plot : module |
| 220 | Plotting context, e.g., ``plt``. |
| 221 | plot_type : str |
| 222 | Type of plot to generate. |
| 223 | tag : str |
| 224 | Unique identifier for the plot. |
| 225 | directory : str, optional |
| 226 | The full specification for the directory location. if |
| 227 | ``directory`` is *None*, then the plot is displayed |
| 228 | interactively. |
| 229 | |
| 230 | Returns |
| 231 | ------- |
| 232 | None : None. |
| 233 | |
| 234 | Raises |
| 235 | ------ |
| 236 | ValueError |
| 237 | Unrecognized data visualization library. |
| 238 | |
| 239 | References |
| 240 | ---------- |
| 241 | |
| 242 | Visualization Libraries: |
| 243 | |
| 244 | * Matplotlib : http://matplotlib.org/ |
| 245 | * Seaborn : https://seaborn.pydata.org/ |
| 246 | * Bokeh : http://bokeh.pydata.org/en/latest/ |
| 247 | |
| 248 | """ |
| 249 | |
| 250 | # Validate visualization library |
| 251 | |
| 252 | if (vizlib == 'matplotlib' or |
| 253 | vizlib == 'seaborn' or |
| 254 | vizlib == 'bokeh'): |
| 255 | # supported library |
| 256 | pass |
| 257 | elif vizlib == 'plotly': |
| 258 | raise ValueError("Unsupported data visualization library: %s" % vizlib) |
| 259 | else: |
| 260 | raise ValueError("Unrecognized data visualization library: %s" % vizlib) |
| 261 | |
| 262 | # Save or display the plot |
| 263 | |
| 264 | if directory: |
| 265 | if vizlib == 'bokeh': |
| 266 | file_only = ''.join([plot_type, USEP, tag, '.html']) |
| 267 | else: |
| 268 | file_only = ''.join([plot_type, USEP, tag, '.png']) |
no outgoing calls
no test coverage detected