Matshow Plot
puma.matshow.MatshowPlot
#
Bases: puma.plot_base.PlotBase
Plot Matrix class.
Plot a matrix with matplotlib matshow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_ticklabels
|
list | None
|
Names of the matrix's columns; if None, indices are shown. by default None |
None
|
x_ticks_rotation
|
int
|
Rotation of the columns' names, by default 90 |
90
|
y_ticklabels
|
list | None
|
Names of the matrix's rows; if None, indices are shown. by default None |
None
|
show_entries
|
bool
|
If True, show matrix entries as numbers in the matrix pixels. by default True |
True
|
show_percentage
|
bool
|
If True, if matrix entries are percentages (i.e. numbers in [0,1]), format them as percentages. by default False |
False
|
text_color_threshold
|
float
|
threshold on the relative luminance of the colormap bkg color after which the text color switches to black, to allow better readability on lighter cmap bkg colors. If 1, all text is white; if 0, all text is black. by default 0.408 |
0.408
|
colormap
|
matplotlib.pyplot.cm
|
Colormap for the plot, by default |
matplotlib.pyplot.cm.Oranges
|
show_cbar
|
bool
|
Whether to plot the colorbar or not, by default True |
True
|
cbar_label
|
str | None
|
Label of the colorbar, by default None |
None
|
**kwargs
|
puma.matshow.MatshowPlot(kwargs)
|
Keyword arguments for |
{}
|
Example
matrix_plotter = MatshowPlot() mat = np.random.rand(4, 3) matrix_plotter.draw(mat)
Source code in puma/matshow.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 |
|
__get_luminance
#
Calculate the relative luminance of a color according to W3C standards. For the details of the conversion see: https://www.w3.org/WAI/GL/wiki/Relative_luminance .
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgbColor
|
tuple
|
(r,g,b,a) color (returned from |
required |
Returns:
Type | Description |
---|---|
float
|
Relative luminance of the color. |
Source code in puma/matshow.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
__plot
#
Plot the Matrix.
Source code in puma/matshow.py
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 |
|
draw
#
Draw a matrix with the class customized appearance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
numpy.ndarray
|
The matrix to be plotted. |
required |
Source code in puma/matshow.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|