polytex.plot
polytex.plot.color_cluster
polytex.plot.image_plot
- polytex.plot.image_plot.lighten_color(color, amount=0.5, alpha=1)[source]
Lightens the given color by multiplying (1-luminosity) by the given amount. Input can be matplotlib color string, hex string, or RGB tuple.
url : https://stackoverflow.com/questions/37765197/darken-or-lighten-a-color-in-matplotlib
- Parameters
- colorstr or tuple
color to lighten
- amountfloat
amount to lighten the color. Value less than 1 produces a lighter color, value greater than 1 produces a darker color.
- alphafloat
alpha value of the color. Default is 1. The alpha value is a float between 0 and 1.
- Returns
- tuple
modified color in RGBA tuple (float values in the range 0-1).
- Examples:
- >> lighten_color(‘g’, 0.3, 1)
- (0.5500000000000002, 0.9999999999999999, 0.5500000000000002, 1)
- >> lighten_color(‘#F034A3’, 0.6, 0.5)
- (0.9647058823529411, 0.5223529411764707, 0.783529411764706, 0.5)
- >> lighten_color((.3,.55,.1), 0.5)
- (0.6365384615384615, 0.8961538461538462, 0.42884615384615377, 1)
- polytex.plot.image_plot.para_plot()[source]
This function is used to describe the parameters of the plot.
- polytex.plot.image_plot.vert_sub_plot(num_plots, vspace, x, y, labels)[source]
This function is used to plot multiple subplots vertically.
- Parameters
- num_plotsint
The number of subplots.
- vspacefloat
The vertical space between subplots.
- xnumpy array
The x-axis data. The shape of x should be (num_points, num_plots).
- ynumpy array
The y-axis data. The shape of y should be (num_points, num_plots).
- labelslist
The labels of subplots.
- Returns
- figmatplotlib.figure.Figure
The figure object.
- polytex.plot.image_plot.xy_interp(*axis_list, num=100, raw=False)[source]
Interpolate the axis_list to the same x-axis and calculate the mean y-axis for all the input x-y pairs (midline).
TODO: check what happens if the range of x-axis is not the same for all the input axis_list.
- Parameters
- axis_listlist of np.ndarray
Each element is a 2D array with shape (n, 2), where n is the number of points. The first column is x-axis and the second column is y-axis.
- numint, optional
The number of points to interpolate. The default is 100.
- rawbool, optional
If True, return the raw interpolated axis_list. The default is False.
- Returns
- midnp.ndarray
The interpolated midline with shape (n, 2), where n is the number of points. The first column is x-axis and the second column is y-axis.
- raw_interpnp.ndarray
The raw interpolated axis_list with shape (n, m), where n is the number of points and m is the number of input axis_list. The first m columns are x-axis and the last m columns are y-axis.
Notes
[algorithm - How to interpolate a line between two other lines in python] (https://stackoverflow.com/questions/49037902/how-to-interpolate-a-line-between-two-other-lines-in-python/49041142#49041142)
Examples
>>> x1 = np.linspace(0, 10, 10) >>> y1 = np.linspace(0, 15, 10) >>> x2 = np.linspace(0, 10, 20) >>> y2 = np.linspace(0, 12, 20) >>> x3 = np.linspace(0, 9, 30) >>> y3 = np.linspace(0, 18, 30) >>> interp(np.vstack((x1, y1)).T, np.vstack((x2, y2)).T, np.vstack((x3, y3)).T)