The simple.roseaxes Namespace
This contains the RoseAxes class and its utility functions.
simple.roseaxes.RoseAxes
RoseAxes(*args, **kwargs)
Bases: PolarAxes
A subclass of matplotlibs Polar Axes.
Rose plots can be created using the create_rose_plot function or by
specifying the projection 'rose' using matplotlib functions.
Only custom and reimplemented methods are described here. See matplotlibs documentation for more methods. Note
however, that these method might not behave as the reimplemented version below. For example the matplotlib methods
will not take into account the xscale and yscale.
Note that some features, like axlines, might require an updated version of matplotlib to work.
Source code in simple/roseaxes.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
name
class-attribute
instance-attribute
name = 'rose'
axmline
axmline(m, r=1, merr=None, eline=True, ecolor=None, elinestyle=':', elinewidth=None, ezorder=None, antipodal=None, **kwargs)
Draw a line along a slope.
Uses matplotlibs axvline method to draw the line(s).
Parameters:
-
m((float, (float, float))) –Either a single slope or a tuple of x and y coordinates from which a slope will be calculated.
-
r((float, (float, float)), default:1) –If a single value is given a line will be drawn between the
0andr. if a tuple of two values are given the line will be drawn betweenr[0]andr[1]. Note these are relative coordinates. -
merr–The uncertainty of the slope.
-
eline–If
Truelines will also be drawn for the uncertainty of the slope. -
ecolor–The color used for the uncertainty lines.
-
elinestyle–The line style used for the uncertainty lines.
-
elinewidth–The line width used for the uncertainty lines.
-
ezorder–The z order width used for the uncertainty lines.
-
antipodal–Whether the antipodal data points will be drawn. By default,
antipodal=Truewhenmis a slope andantipodal=Falsewhenmis x,y coordinates. -
**kwargs–Additional keyword arguments passed to matplotlibs axvline method.
Source code in simple/roseaxes.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
axrline
axrline(r, tmin=0, tmax=1, **kwargs)
Plot a line along a given radius.
Used matplotlibs axhline method to draw the line.
Parameters:
-
r–The radius at which to draw the line.
-
tmin–The starting angle of the line. In relative coordinates.
-
tmax–The stopping angle of the line. In relative coordinates.
-
**kwargs–Additional keyword arguments passed to matplotlibs axhline method.
Returns:
Source code in simple/roseaxes.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
clear
clear()
Clear the ax.
Source code in simple/roseaxes.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
get_rres
get_rres()
Return the resolution of lines drawn along the radius r.
Source code in simple/roseaxes.py
279 280 281 282 283 | |
get_xyscale
get_xyscale()
Return a tuple of the scale of the x and y dimensions of the rose diagram.
Source code in simple/roseaxes.py
219 220 221 222 223 | |
merrorbar
merrorbar(m, r=1, merr=None, antipodal=None, **kwargs)
Plot data points with errorbars.
This is an adapted version of matplotlibs errorbar method.
Note it is currently not possible to add bar ends to the error bars.
Parameters:
-
m((float, (float, float))) –Either a single array of floats representing a slope or a tuple of x and y coordinates from which a slope will be calculated.
-
r–The radius at which the data points will be drawn.
-
merr–The uncertainty of the slope.
-
antipodal–Whether the antipodal data points will be drawn. By default,
antipodal=Truewhenmis a slope andantipodal=Falsewhenmis x,y coordinates. -
**kwargs–Additional keyword arguments passed to matplotlibs
-
[errorbar](https–//matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.errorbar.html) method.
Source code in simple/roseaxes.py
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 384 385 386 387 388 389 390 391 | |
mhist
mhist(m, r=None, weights=1, color=None, *, rheight=0.9, rescale=False, antipodal=None, bins=72, rtext=None, fill=True, outline=None, update_rticks=True, minor_rticks=2, rscale=True, cmap=False, **kwargs)
Create a histogram of the given slopes.
Parameters:
-
m((float, (float, float))) –Either a single array of floats representing a slope or a tuple of x and y coordinates from which a slope will be calculated.
-
r–The radius at which the histogram will be drawn. If 'None' it will be plotted
1above the previous histogram, or at 1 if no histogram have been drawn. -
color–The color of the bars and the outline of the bars.
-
weights–The weight assigned to each slope.
-
rheight–The height of the histogram. If
rscale=Truethis is the relative height of the histogram. Otherwise the cumulative height of all the bins will total to this value. -
rescale–If
Trueall bin heights will be scaled relative to the heaviest bin. Otherwise, they are scaled relative to the sum of all bin weights or the range set by the colormap. -
antipodal–Whether the antipodal data points will be included in the histogram. By default,
-
bins–The number of even sized bin in the histogram.
-
rtext–A text label for the histogram in the plot. Created using the
rtextmethod. Keyword arguments can be passed using the prefixrtext_. -
fill(bool, default:True) –If
Truethe bars will be filled in. -
outline–If
Truethe bar will be drawn with an outline. IfFalseno outline will be drawn. -
update_rticks–If
Truethe y axis ticks will be updated to include the radius of the histogram. -
minor_rticks–The number of minor ticks to draw between the major ticks.
-
rscale–If
Trueheight of the individual bins will be scaled to their weight. Otherwise all bins will have the same height. -
cmap–If
True, or the name of a colormap, the bars be coloured depending on their weight based on the colour map. IfFalseall bars will have the same colour based on color. -
**kwargs–Additional keyword arguments. A description of accepted keywords is provided below.
Accepted keyword arguments
Direct keywords:
- zorder the zorder of the bars and outline. The outline will be drawn on top of the bars.
- label the label of the histogram. Note that the label is created as an emtpy artist to ensure
consistensy with the label on 1-d histograms.
- linestyle, linewidth the linestyle and linewidth of the outline and baseline. Can be set
individually using the prefix outline_ and baseline_ respectively.
Prefixed keywords:
- fill_<keyword>: Keywords passed to PolarAxes.fill_between when drawing the bars.
- outline_<keyword>: Keywords passed to PolarAxes.plot when drawing the outline.
- baseline_<keyword>: Keywords passed to PolarAxes.plot when drawing the baseline.
- rtext_<keyword>: Keywords passed to PolarAxes.rtext when drawing the text label.
Source code in simple/roseaxes.py
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | |
mline
mline(m, r=1, merr=None, antipodal=None, *, eline=True, efill=False, ecolor=None, elinestyle=':', elinewidth=None, ezorder=None, ealpha=0.1, **kwargs)
Draw a line along a slope.
Used matplotlibs plot method to draw the line(s).
Parameters:
-
m((float, (float, float))) –Either a single slope or a tuple of x and y coordinates from which a slope will be calculated.
-
r((float, (float, float)), default:1) –If a single value is given a line will be drawn between the
0andr. if a tuple of two values are given the line will be drawn betweenr[0]andr[1]. Note these are absolute coordinates. -
merr–The uncertainty of the slope.
-
eline–If
Truelines will also be drawn for the uncertainty of the slope. -
efill–If
Truethe area defined by the uncertainty of the slope will be shaded. -
ecolor–The color used for the uncertainty lines and/or the shaded area.
-
elinestyle–The line style used for the uncertainty lines.
-
elinewidth–The line width used for the uncertainty lines.
-
ezorder–The z order width used for the uncertainty lines.
-
ealpha–The alpha value for the shaded area.
-
antipodal–Whether the antipodal data points will be drawn. By default,
antipodal=Truewhenmis a slope andantipodal=Falsewhenmis x,y coordinates. -
**kwargs–Additional keyword arguments passed to matplotlibs plot method.
Source code in simple/roseaxes.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
rtext
rtext(text, r, deg=0, rotation=None, **kwargs)
Source code in simple/roseaxes.py
543 544 545 546 547 548 549 550 551 552 553 554 | |
set_colorbar
set_colorbar(vmin=None, vmax=None, log=False, cmap='turbo', label=None, fontsize=None, show=True, ax=None, clear=True)
Define the colorbar used for histograms.
Currently, there is no way to delete any existing colorbars. Thus, everytime this function is called a new colorbar is created. Therefore, It's advisable to only call this method once.
Parameters:
-
vmin(float, default:None) –The lower limit of the colour map. If no value is given the minimum value is
0(or1E-10iflog=True) -
vmax(float, default:None) –The upper limit of the colour map. If no value is given then
vmaxis set to1and all bin default_weight are divided by the heaviest bin weight in each histogram. -
log(bool, default:False) –Whether the color map scale is logarithmic or not.
-
cmap–The prefixes of the colormap to use. See, [matplotlib documentation][https://matplotlib.org/stable/users/explain/colors/colormaps.html] for a list of available colormaps.
-
label–The label given to the colorbar.
-
fontsize–The fontsize of the colorbar label.
-
show–Whether to add a colorbar to the figure.
-
ax–The axis where the colorbar is drawn. If
Noneit will be drawn on the right of the current axes. -
clear–If
Truethe current axes will be cleared.
Source code in simple/roseaxes.py
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 | |
set_rres
set_rres(rres)
Set the resolution of lines drawn along the radius r. The number of points in a line is calculated as
r*rres+1 (Min. 2).
Source code in simple/roseaxes.py
272 273 274 275 276 277 | |
set_xyscale
set_xyscale(xscale, yscale)
Set the scale of the x and y dimensions of the rose diagram.
This can be used to distort the diagram to e.g. better show large or small slopes.
Note Should not be confused with matplotlibs set_xscale and the set_yscale methods. They
are used to set the type of scale, e.g. log, linear etc., used for the different axis.
Calling this method will clear the current axes as it cannot update what has already been drawn.
Parameters:
-
xscale(float) –The scale of the x dimension of the rose diagram.
-
yscale(float) –The scale of the y dimension of the rose diagram.
Source code in simple/roseaxes.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
set_xysegment
set_xysegment(segment)
Define which segment of the rose diagram to show.
Parameters:
-
segment–Options are
N,E,S,W,None. IfNonethe entire circle is shown.
Source code in simple/roseaxes.py
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 | |
simple.roseaxes.as0darray
as0darray(*a, dtype=np.float64)
Source code in simple/roseaxes.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
simple.roseaxes.as1darray
as1darray(*a, dtype=np.float64)
Source code in simple/roseaxes.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
simple.roseaxes.deg2rad
deg2rad(deg)
Convert a degree angle into a radian angle`value
Source code in simple/roseaxes.py
83 84 85 | |
simple.roseaxes.get_cmap
get_cmap(name)
Return the matplotlib colormap with the given name.
Source code in simple/roseaxes.py
93 94 95 96 97 98 | |
simple.roseaxes.rad2deg
rad2deg(rad)
Convert a degree angle into a radian angle`value
Source code in simple/roseaxes.py
88 89 90 | |
simple.roseaxes.xy2deg
xy2deg(x, y, xscale=1.0, yscale=1.0)
Convert x, y coordinated into a angle value given in degrees.
Source code in simple/roseaxes.py
75 76 77 78 79 80 | |
simple.roseaxes.xy2rad
xy2rad(x, y, xscale=1.0, yscale=1.0)
Convert x, y coordinated into a angle value given in radians.
Source code in simple/roseaxes.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |