Builder
PlotBuilder
PlotBuilder is a class whose intent is to uase the user in plot customization. Using PlotBuilder with jupyther/notebook is strongly recomended as changes are interactive and figures are preserved.
Source code in itfit/plot/builder.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
__init__(app, **kargs)
grid(*args, **kwargs)
Toggles the grid in the plot.
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
labels()
Starts labels builder. After calling it xlabel and ylabel can be accessed.
Returns:
Type | Description |
---|---|
itfit.plot.labels.LabelBuilder
|
label builder. |
legend(*args, **kargs)
Toggles the legend in the plot.
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
plot_data(fmt='.', color=None, label='', only_selected=False, yerr=True, xerr=True, **kargs)
Plots the data fitted into the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
Data line format. Defaults to '.'. |
'.'
|
color |
str
|
Color for the line. Defaults to None. |
None
|
label |
str
|
Label assigned to the artists. Defaults to ''. |
''
|
only_selected |
bool
|
Shows only selected data. Defaults to |
False
|
yerr |
bool
|
Shows data errors in y coordinate if given. Defaults to |
True
|
xerr |
bool
|
Shows data errors in y coordinate if given. Defaults to |
True
|
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
plot_data_errors(axis='y', ecolor=None, elinewidth=None, capsize=1, errorsevery=1, **kargs)
Plots error bars on data. Must be called after data has been plotted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str | bool
|
Axis in which to plot error bars. Defaults to y. |
'y'
|
ecolor |
str | tuple[float] | None
|
Sets the color of the error bar. Defaults to None. |
None
|
elinewidth |
float | None
|
Sets the line width of the error bar. Defaults to None. |
None
|
capsize |
float | None
|
Controls the length of the error bar cap in points. Defaults to 1. |
1
|
errorsevery |
int | tuple[int, int]
|
Draws error bars on a subset of the data. e.g. every=(3,4) then error bars would be on |
1
|
x[3], x[7], x[11].... Defaults to 1.
Raises:
Type | Description |
---|---|
Exception
|
If used prior to data plotting. |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
plot_fit(fmt='--', color='black', label='', only_selected_data=False, **kargs)
Plots the fit line into the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
Fit line format. Defaults to '--'. |
'--'
|
color |
str
|
Color for the line. Defaults to 'black'. |
'black'
|
label |
str
|
Label assigned to the artists. Defaults to ''. |
''
|
only_selected_data |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
plot_fit_errors(color=None, edgecolor='None', alpha=0.3, only_selected='auto', **kargs)
Plots error shadow on fit. Must be called after fit has been plotted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
str | tuple[float] | None
|
Fill color. Defaults to None. |
None
|
edgecolor |
str
|
Color of the error shadow edges. Defaults to 'None'. |
'None'
|
alpha |
float
|
Alpha value. Defaults to 0.3. |
0.3
|
only_selected |
str | bool
|
If False error will be shown for all data range. Defaults to 'auto'. |
'auto'
|
Raises:
Type | Description |
---|---|
Exception
|
If used prior to fit plotting. |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
save_fig(filename, transparent=False, **kargs)
Saves the figure with the given filename
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
set_size(size, unit='cm')
Sets the figure size, be default in centimeters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
float
|
left limit. |
required |
unit |
float
|
right limit. Default='cm'. |
'cm'
|
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
set_xlim(left, right, **kargs)
Sets the left and right plot limits on x axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left |
float
|
left limit. |
required |
right |
float
|
right limit. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
set_ylim(bottom, top, **kargs)
Sets the bottom and top plot limits on y axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bottom |
float
|
bottom limit. |
required |
top |
float
|
top limit. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
show_inline()
Returns the figure. When used in Jupyter shows the figure in the cell output.
Returns:
Type | Description |
---|---|
matplotlib.Figure
|
PlotBuilder's figure. |
spines()
style(style)
Sets the style. Must be executed befor start
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style |
str
|
Style to use. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
tight_layout(**kargs)
Adjust the padding between and around subplots.
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
title(title)
Shortcut to .labels().start_title(title).end_title().end_labels()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Title string. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
with_data(fmt='.', color=None, label='', only_selected=False, yerr=True, xerr=True, **kargs)
Same as itfit.plot.builder.PlotBuilder.plot_data. Plots the data fitted into the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
Data line format. Defaults to '.'. |
'.'
|
color |
str
|
Color for the line. Defaults to None. |
None
|
label |
str
|
Label assigned to the artists. Defaults to ''. |
''
|
only_selected |
bool
|
Shows only selected data. Defaults to |
False
|
yerr |
bool
|
Shows data errors in y coordinate if given. Defaults to |
True
|
xerr |
bool
|
Shows data errors in y coordinate if given. Defaults to |
True
|
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
with_errors(axis='y', ecolor=None, elinewidth=None, capsize=1, errorsevery=1, **kargs)
Same as itfit.plot.builder.PlotBuilder.plot_data_errors. Plots error bars on data. Must be called after data has been plotted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str | bool
|
Axis in which to plot error bars. Defaults to y. |
'y'
|
ecolor |
str | tuple[float] | None
|
Sets the color of the error bar. Defaults to None. |
None
|
elinewidth |
float | None
|
Sets the line width of the error bar. Defaults to None. |
None
|
capsize |
float | None
|
Controls the length of the error bar cap in points. Defaults to 1. |
1
|
errorsevery |
int | tuple[int, int]
|
Draws error bars on a subset of the data. e.g. every=(3,4) then error bars would be on |
1
|
x[3], x[7], x[11].... Defaults to 1.
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
with_fit(fmt='--', color='black', label='', only_selected=False, **kargs)
Same as itfit.plot.builder.PlotBuilder.plot_fit. Plots the fit line into the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fmt |
str
|
Fit line format. Defaults to '--'. |
'--'
|
color |
str
|
Color for the line. Defaults to 'black'. |
'black'
|
label |
str
|
Label assigned to the artists. Defaults to ''. |
''
|
only_selected |
bool
|
Shows fit only on selected data range. Defaults to |
False
|
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
xlabel(xlabel)
Shortcut to .labels().start_x_label(xlabel).end_xlabel().end_labels()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlabel |
str
|
x label string. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |
Source code in itfit/plot/builder.py
ylabel(ylabel)
Shortcut to .labels().start_y_label(ylabel).end_ylabel().end_labels()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ylabel |
str
|
y label string. |
required |
Returns:
Type | Description |
---|---|
itfit.plot.builder.PlotBuilder
|
Returns itself to continue building the plot. |