Package: plotstring
IntroductionThis sample package contain just one function "plot", this function canplota numerical data x,y as a stringThe string plot can be helpful to be used in comments, on in bloc-notes, ...The plot is a normal string that can be used anywheresee the below example: Price of the BTC plot as string# You can put the code her# Below the plot as a comments'''Price of the BTC: January 2023, High, finance.yahooHigh price (USD)----------------------------------------------**-|2.51e+04|                                             ***||                               *            ****||                       *   ** ***           ****||                   *   *** ******** **      ****||                   ********************     ****|2.30e+04|                  *********************     ****||                  *********************  * *****||                * ******************************||              **********************************||            ************************************|2.09e+04|            ************************************||           *************************************||           *************************************||          **************************************||          **************************************|1.88e+04|          **************************************||         ***************************************||       *****************************************||  **********************************************|*************************************************|1.66e+04¦1.00e+00   ¦1.30e+01   ¦2.50e+01   ¦3.70e+01   ¦4.90e+01Day of January 2023'''# Example of code linea=NoneInstallationPyPi installation!pip install plotstringInstallation form githubDownload the zip fromhttps://github.com/bouz1/Plot_AS_Stringand unzip the fileOr clone the reposotory in local by the cmd: git clonehttps://github.com/bouz1/Plot_AS_String.gitRun cmd in the folder that contain the setup.pyExcute the cmd: pip install .Libraries# The main library : plotstringfromplotstringimportplot# Other libraries to test plotstringimportnumpyasnpimportpandasaspdimportpyperclipUsing of the function "plot"Helpyou can use Help to see the function descriptionhelp(plot)Help on function plot in module plotstring:

plot(df=None, Nx=80, Ny=32, title='Title', xlabel=None, ylabel=None, print_str=True, return_str=True, copy_out_clipbrd=True, markers='*', N_grid=2, bar=False, x_int=False)
    Create a plot of the data in the clipboard AS STRING.
    The plot can be used as a normal string in comments, bloc-notes, ... 
    
    :param df: DataFrame, optional
        The DataFrame to plot. If not provided, the function reads from the clipboard.
    :param Nx: int, optional
        The number of horizontal pixels in the plot.
    :param Ny: int, optional
        The number of vertical pixels in the plot.
    :param title: str, optional
        The title of the plot.
    :param xlabel: str, optional
        The label for the x-axis. if not provided, the function will use df columns.
    :param ylabel: str, optional
        The label for the y-axis. if not provided, the function will use df columns.
    :param print_str: bool, optional
        Whether to print the plot as a string.
    :param return_str: bool, optional
        Whether to return the plot as a string.
    :param copy_out_clipbrd: bool, optional
        Whether to copy the plot to the clipboard.
    :param markers: str, optional
        The marker to use for the plot.
    :param N_grid: int, optional
        The number of grid lines to use.
    :param bar: bool, optional
        Whether to use a bar plot instead of a line plot.
    :param x_int: bool, optional
        Whether the x is an integer or not.
    :return: None or str
        If `print_str` is True, the plot is printed as a string. If `return_str` is True, the plot is returned as a string. Otherwise, None is returned.Use plot by passing a DataFrameIn this first example, the plot function use a dataFrame as inputPrepare data to test the plot functionx=np.arange(0,360,10)y=np.sin(x*np.pi/180)df=pd.DataFrame(zip(x,y),columns=['angle','sin_angle'])df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>anglesin_angle000.0000001100.1736482200.3420203300.5000004400.642788Use our funciton plot with a dataFrame as inputoutput_string=plot(df)Title                                     
                                                                                sin_angle
------------------*--*-*---------------------------------------------------------|1.00e+00
|               *        *              |                                        |
|             *            *            |                                        |
|                                       |                                        |
|          *                  *         |                                        |
|                                       |                                        |
|        *                      *       |                                        |
|                                       |                                        |
|      *                          *     |                                        |5.00e-01
|                                       |                                        |
|                                       |                                        |
|    *                               *  |                                        |
|                                       |                                        |
| *                                    *|                                        |
|                                       |                                        |
|                                       |                                        |
*----------------------------------------*---------------------------------------|0.00e+00
|                                       |                                        |
|                                       |                                        |
|                                       |  *                                    *|
|                                       |                                        |
|                                       |     *                               *  |
|                                       |                                        |
|                                       |                                        |
|                                       |       *                          *     |-5.00e-01
|                                       |                                        |
|                                       |         *                      *       |
|                                       |                                        |
|                                       |            *                 *         |
|                                       |                                        |
|                                       |              *             *           |
|                                       |                *        *              |
-----------------------------------------------------------*--*-*----------------|-1.00e+00
¦0.00e+00           ¦8.75e+01           ¦1.75e+02           ¦2.62e+02           ¦3.50e+02
angleuse plot by CTRL + CIn this second example, the plot function can use directly the data in your clipboard,you can for example copy the data directly from an excel file, and run the plot function to plot your dataExample of the data that you can copy in your clipboard using simply the habitual keys CTRL+Cstring='''angle	sin_angle-90	6.12E-17-80	1.74E-01-70	3.42E-01-60	5.00E-01-50	6.43E-01-40	7.66E-01-30	8.66E-01-20	9.40E-01-10	9.85E-010	1.00E+0010	9.85E-0120	9.40E-0130	8.66E-0140	7.66E-0150	6.43E-0160	5.00E-0170	3.42E-0180	1.74E-0190	6.12E-17'''You can copy the above data, but for this example we will use pyperclip.copy to copy the string by code (this can be helpful if we run the entire notebook)pyperclip.copy(string)# Plot the copied dataoutput_string=plot()Title                                     
                                                                                sin_angle
------------------------------------*---*---*------------------------------------|1.00e+00
|                                       |                                        |
|                              *        |        *                               |
|                                       |                                        |
|                          *            |            *                           |
|                                       |                                        |
|                                       |                                        |
|                     *                 |                 *                      |
|                                       |                                        |7.50e-01
|                                       |                                        |
|                                       |                                        |
|                 *                     |                     *                  |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
-------------*-----------------------------------------------------*-------------|5.00e-01
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
|        *                              |                              *         |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |2.50e-01
|                                       |                                        |
|   *                                   |                                   *    |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
|                                       |                                        |
*-------------------------------------------------------------------------------*|6.12e-17
¦-9.00e+01          ¦-4.50e+01          ¦0.00e+00           ¦4.50e+01          ¦9.00e+01
angleOther parameters of the plot functionPrepare data for this third examplex=np.arange(-3,3.2,0.2)y=np.exp(-(x**2))df=pd.DataFrame(zip(x,y),columns=['angle','Norm PDF'])The plot data with all parametersWithout returning the string, and without copying the string in the clipboardplot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.title='PDF',# The title of the plot.xlabel='X axis',# The label for the x-axis. if not provided, the function will use df columns.ylabel='y axis',# The label for the y-axis. if not provided, the function will use df columns.print_str=True,# Whether to print the plot as a string.return_str=False,# Whether to return the plot as a string.copy_out_clipbrd=False,# Whether to copy the plot to the clipboard.markers='*',# The marker to use for the plot.N_grid=1,# The number of grid lines to use.bar=True,# Whether to use a bar plot instead of a line plot.x_int=False# Whether the x is an integer or not)PDF                                      
                                                                                y axis
----------------------------------------*----------------------------------------|1.00e+00
|                                    *  *  *                                     |
|                                    *  *  *                                     |
|                                  * *  *  * *                                   |
|                                  * *  *  * *                                   |
|                                  * *  *  * *                                   |7.50e-01
|                               *  * *  *  * *  *                                |
|                               *  * *  *  * *  *                                |
|                               *  * *  *  * *  *                                |
|                            *  *  * *  *  * *  *  *                             |
|                            *  *  * *  *  * *  *  *                             |5.00e-01
|                            *  *  * *  *  * *  *  *                             |
|                            *  *  * *  *  * *  *  *                             |
|                          * *  *  * *  *  * *  *  * *                           |
|                          * *  *  * *  *  * *  *  * *                           |
|                       *  * *  *  * *  *  * *  *  * *  *                        |2.50e-01
|                       *  * *  *  * *  *  * *  *  * *  *                        |
|                    *  *  * *  *  * *  *  * *  *  * *  *  *                     |
|                  * *  *  * *  *  * *  *  * *  *  * *  *  * *                   |
|               *  * *  *  * *  *  * *  *  * *  *  * *  *  * *  *                |
*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*|1.23e-04
¦-3.00e+00          ¦-1.50e+00          ¦0.00e+00           ¦1.50e+00          ¦3.00e+00
X axisWithout printing the string, and without copying the string in the clipboard, the function will return the stringstr_out=plot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.title='PDF',# The title of the plot.xlabel='X axis',# The label for the x-axis. if not provided, the function will use df columns.ylabel='y axis',# The label for the y-axis. if not provided, the function will use df columns.print_str=False,# Whether to print the plot as a string.return_str=True,# Whether to return the plot as a string.copy_out_clipbrd=False,# Whether to copy the plot to the clipboard.markers='*',# The marker to use for the plot.N_grid=1,# The number of grid lines to use.bar=True,# Whether to use a bar plot instead of a line plot.x_int=False# Whether the x is an integer or not)you can use the retuned stringprint(str_out)PDF                                      
                                                                                y axis
----------------------------------------*----------------------------------------|1.00e+00
|                                    *  *  *                                     |
|                                    *  *  *                                     |
|                                  * *  *  * *                                   |
|                                  * *  *  * *                                   |
|                                  * *  *  * *                                   |7.50e-01
|                               *  * *  *  * *  *                                |
|                               *  * *  *  * *  *                                |
|                               *  * *  *  * *  *                                |
|                            *  *  * *  *  * *  *  *                             |
|                            *  *  * *  *  * *  *  *                             |5.00e-01
|                            *  *  * *  *  * *  *  *                             |
|                            *  *  * *  *  * *  *  *                             |
|                          * *  *  * *  *  * *  *  * *                           |
|                          * *  *  * *  *  * *  *  * *                           |
|                       *  * *  *  * *  *  * *  *  * *  *                        |2.50e-01
|                       *  * *  *  * *  *  * *  *  * *  *                        |
|                    *  *  * *  *  * *  *  * *  *  * *  *  *                     |
|                  * *  *  * *  *  * *  *  * *  *  * *  *  * *                   |
|               *  * *  *  * *  *  * *  *  * *  *  * *  *  * *  *                |
*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*|1.23e-04
¦-3.00e+00          ¦-1.50e+00          ¦0.00e+00           ¦1.50e+00          ¦3.00e+00
X axisWithout printing the string, and without returning the string in the clipboard, the function will copy the string in your clipboardplot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.title='PDF',# The title of the plot.xlabel='X axis',# The label for the x-axis. if not provided, the function will use df columns.ylabel='y axis',# The label for the y-axis. if not provided, the function will use df columns.print_str=False,# Whether to print the plot as a string.return_str=False,# Whether to return the plot as a string.copy_out_clipbrd=True,# Whether to copy the plot to the clipboard.#markers='*',             # The marker to use for the plot.N_grid=1,# The number of grid lines to use.bar=True# Whether to use a bar plot instead of a line plot.)You can past the string anywhere, you can ofcore use the keys CTRL + V to paste the string, example of pasting'''PDFy axis----------------------------------------*----------------------------------------|1.00e+00|                                    *  *  *                                     ||                                    *  *  *                                     ||                                  * *  *  * *                                   ||                                  * *  *  * *                                   ||                                  * *  *  * *                                   |7.50e-01|                               *  * *  *  * *  *                                ||                               *  * *  *  * *  *                                ||                               *  * *  *  * *  *                                ||                            *  *  * *  *  * *  *  *                             ||                            *  *  * *  *  * *  *  *                             |5.00e-01|                            *  *  * *  *  * *  *  *                             ||                            *  *  * *  *  * *  *  *                             ||                          * *  *  * *  *  * *  *  * *                           ||                          * *  *  * *  *  * *  *  * *                           ||                       *  * *  *  * *  *  * *  *  * *  *                        |2.50e-01|                       *  * *  *  * *  *  * *  *  * *  *                        ||                    *  *  * *  *  * *  *  * *  *  * *  *  *                     ||                  * *  *  * *  *  * *  *  * *  *  * *  *  * *                   ||               *  * *  *  * *  *  * *  *  * *  *  * *  *  * *  *                |*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*--*-*--*|1.23e-04¦-3.00e+00          ¦-1.50e+00          ¦0.00e+00           ¦1.50e+00          ¦3.00e+00X axis'''_=0You can chnage Nx, Ny_=plot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=20,# The number of horizontal pixels in the plot.Ny=10# The number of vertical pixels in the plot.)Title       
                    Norm PDF
---------***---------|1.00e+00
|        *|*         |
|         |          |8.00e-01
|       * | *        |
|         |          |6.00e-01
-------*-----*-------|
|      *  |  *       |4.00e-01
|         |          |
|     *   |   *      |2.00e-01
|    *    |    *     |
*****-----------*****|1.23e-04
¦-3.0¦-1.5¦0.00¦1.50e+00¦3.00e+00
angleYou can change the number of grid lines "N_grid", trick: preferably you can use N_grid  as common divisor of Nx, Ny_=plot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.N_grid=5,# The number of grid lines to use.)Title                                     
                                                                                Norm PDF
----------------------------------------*----------------------------------------|1.00e+00
|               |               |    *     *    |               |                |
|               |               |               |               |                |
|               |               |  *         *  |               |                |
---------------------------------------------------------------------------------|
|               |               |               |               |                |7.50e-01
|               |               *               *               |                |
|               |               |               |               |                |
---------------------------------------------------------------------------------|
|               |            *  |               |  *            |                |
|               |               |               |               |                |5.00e-01
|               |               |               |               |                |
---------------------------------------------------------------------------------|
|               |          *    |               |    *          |                |
|               |               |               |               |                |
|               |       *       |               |       *       |                |2.50e-01
---------------------------------------------------------------------------------|
|               |    *          |               |          *    |                |
|               |  *            |               |            *  |                |
|               *               |               |               *                |
*--*-*--*--*-*-----------------------------------------------------*-*--*--*-*--*|1.23e-04
¦-3.00e+00          ¦-1.50e+00          ¦0.00e+00           ¦1.50e+00          ¦3.00e+00
angleX as integer_=plot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.N_grid=5,# The number of grid lines to use.x_int=True# Whether the x is an integer or not)Title                                     
                                                                                Norm PDF
----------------------------------------*----------------------------------------|1.00e+00
|               |               |    *     *    |               |                |
|               |               |               |               |                |
|               |               |  *         *  |               |                |
---------------------------------------------------------------------------------|
|               |               |               |               |                |7.50e-01
|               |               *               *               |                |
|               |               |               |               |                |
---------------------------------------------------------------------------------|
|               |            *  |               |  *            |                |
|               |               |               |               |                |5.00e-01
|               |               |               |               |                |
---------------------------------------------------------------------------------|
|               |          *    |               |    *          |                |
|               |               |               |               |                |
|               |       *       |               |       *       |                |2.50e-01
---------------------------------------------------------------------------------|
|               |    *          |               |          *    |                |
|               |  *            |               |            *  |                |
|               *               |               |               *                |
*--*-*--*--*-*-----------------------------------------------------*-*--*--*-*--*|1.23e-04
¦-3                 ¦-1                 ¦0                  ¦1                 ¦3
angleChange the markers_=plot(df,#The DataFrame to plot. If not provided, the function reads from the clipboard.Nx=80,# The number of horizontal pixels in the plot.Ny=20,# The number of vertical pixels in the plot.N_grid=1,# The number of grid lines to use.markers='|',# The marker to use for the plot.bar=True,# Whether to use a bar plot instead of a line plot.x_int=False# Whether the x is an integer or not)Title                                     
                                                                                Norm PDF
----------------------------------------|----------------------------------------|1.00e+00
|                                    |  |  |                                     |
|                                    |  |  |                                     |
|                                  | |  |  | |                                   |
|                                  | |  |  | |                                   |
|                                  | |  |  | |                                   |7.50e-01
|                               |  | |  |  | |  |                                |
|                               |  | |  |  | |  |                                |
|                               |  | |  |  | |  |                                |
|                            |  |  | |  |  | |  |  |                             |
|                            |  |  | |  |  | |  |  |                             |5.00e-01
|                            |  |  | |  |  | |  |  |                             |
|                            |  |  | |  |  | |  |  |                             |
|                          | |  |  | |  |  | |  |  | |                           |
|                          | |  |  | |  |  | |  |  | |                           |
|                       |  | |  |  | |  |  | |  |  | |  |                        |2.50e-01
|                       |  | |  |  | |  |  | |  |  | |  |                        |
|                    |  |  | |  |  | |  |  | |  |  | |  |  |                     |
|                  | |  |  | |  |  | |  |  | |  |  | |  |  | |                   |
|               |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |                |
|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--|--|-|--||1.23e-04
¦-3.00e+00          ¦-1.50e+00          ¦0.00e+00           ¦1.50e+00          ¦3.00e+00
angleBTC prices='''Day	High1	16630.439452	16759.343753	16760.447274	16964.585945	16884.021486	16991.994147	16975.017588	17091.144539	17389.9570310	17484.720711	17934.8964812	19030.0878913	19964.3222714	21075.1425815	20993.7480516	21360.87517	21438.6601618	21564.5019519	21163.0117220	22692.3574221	23282.3476622	23056.7304723	23126.4863324	23134.0117225	23722.0996126	23237.0781327	23417.720728	23165.8964829	23919.8906330	23789.3476631	23225.0214832	23764.5390633	24167.2109434	23678.1035235	23556.9492236	23423.4355537	23119.279338	23310.9746139	23367.9589840	22996.437541	21941.1855542	21891.4101643	22060.9941444	21898.4140645	22293.1406346	24307.841847	25134.1171948	24924.0410249	24798.83594'''pyperclip.copy(s)_=plot(bar=True,Nx=48,Ny=20,N_grid=1,title='Price of the BTC: January 2023, High, finance.yahoo',xlabel='Day of January 2023',ylabel='High price (USD)',x_int=True)Price of the BTC: January 2023, High, finance.yahoo
                                                High price (USD)
----------------------------------------------**-|2.51e+04
|                                             ***|
|                               *            ****|
|                       *   ** ***           ****|
|                   *   *** ******** **      ****|
|                   ********************     ****|2.30e+04
|                  *********************     ****|
|                  *********************  * *****|
|                * ******************************|
|              **********************************|
|            ************************************|2.09e+04
|            ************************************|
|           *************************************|
|           *************************************|
|          **************************************|
|          **************************************|1.88e+04
|          **************************************|
|         ***************************************|
|       *****************************************|
|  **********************************************|
*************************************************|1.66e+04
¦1          ¦13         ¦25         ¦37         ¦49
Day of January 2023