Can anyone tell me what thing i have to learn to achive this project

i have an excel file. from there i want to fetch data and output will be in charts form where it is in list format with arrows. i want to know what tools should i learn for doing this .

It isn’t clear to me from the sketch what you output needs to be.

I tend to use openpyxl to read data from Excel files.

If you’re working with data in general though the quick thing to install
is probably pandas, which has a read_excel function and many data
manipulation facilities.

What exactly does this mean?

For example, do you want to create a picture (PNG file, JPG file etc.)?

Do you want to create a PDF or other similar document?

Are you trying to create a web page (HTML), so that the text can be selected out of the “charts” that are shown?

Something else?

my source will be excel file, i want the output in chart view, like the output i am showing in picture
suppose two price given 10 and 50 , and its in sorted
so in out put 10 to 50 will be in list format with border, and an arrow striking in between from small first price to last price

when the next two numbers taken from file, it will do same but then the last output should also be in output window in sequence order.

if still not cleared i will redo the output format and share the pic here

The problem is that “chart” does not properly describe a kind of output file.

umm i want my output in that format , it will be like chart a chart not meaning those chart like bar, pie
or atleast i can see my output as required, on screen whether it is actual chart or not that seconday for me .

my output in a list, and with arrows

I don’t know how to explain this any better.

“I know what it should look like” is not enough in order to design the output.

Ah, so you want a Python program to drive an XY Pen Plotter to draw these figures for you on physical paper…

You are answering the wrong question. People are asking: Do you want to generate a static raster image, like a PNG or JPEG? Do you want a vector image like an SVG? Or do you need some kind of HTML output? Something else? Does this figure need to be interactive in any way? You need to be more explicit about your actual requirements, because “I need a figure that looks like this” could have a hundred different answers, depending.

3 Likes

Hi,

if you want to create a figure, I found this code. Maybe you can test it to see if it suits your application.

#import packages
import pandas as pd
import matplotlib.pyplot as plt

fig, ax = plt.subplots(1,1)

# This is arbitrary data.  In your application, read it from an excel file
# and format it for plotting as shown here
data = [[21],
       [32],
       [46],
        [37],
        [45]]

column_labels = ["Data"]

#creating a 2-dimensional dataframe out of the given data
df = pd.DataFrame(data,columns = column_labels)

ax.axis('tight') #turns off the axis lines and labels
ax.axis('off') #changes x and y axis limits such that all data is shown

#plotting data
table = ax.table(cellText = df.values,
        colLabels = df.columns,
        rowLabels = ["1", "2", "3", "4", "5",],
        rowColours = ["blue"] * 5,
        colColours = ["red"] * 5,
        loc = "center")

table.set_fontsize(12)
table.scale(0.1,1.5) # (width, height)
plt.show()

I found it here:

I modified it slightly so that it only plots one column and five rows as per your sketch. Look into it to see if you can plot multiple single column tables as per your sketch.

1 Like

Hi,

I modified the script such that there are two plots in one graph. I got additional information from this website:

In the following code, I have plotted two multiple row, one column tables:

#import packages
import pandas as pd
import matplotlib.pyplot as plt

fig_1, (ax_1, ax_2) = plt.subplots(2,1)  # (# of rows, # of columns)  defines layout of plots

#fig_2, ax_2 = plt.subplots(1,1)

# This is arbitrary data.  In your application, read it from an excel file
# and format it for plotting as shown here
data_1 = [[21],
       [32],
       [46],
        [37],
        [45]]

column_labels_1 = ["Data 1"]

#creating a 2-dimensional dataframe out of the given data
df_1 = pd.DataFrame(data_1, columns = column_labels_1)

ax_1.axis('tight') #turns off the axis lines and labels
ax_1.axis('off') #changes x and y axis limits such that all data is shown

#plotting data
table_1 = ax_1.table(cellText = df_1.values,
        colLabels = df_1.columns,
        rowLabels = ["1", "2", "3", "4", "5",],
        rowColours = ["blue"] * 5,
        colColours = ["red"] * 5,
        loc = "center")

# -----------------------------------------------------------------------

data_2 = [[35],
       [37],
       [86],
        [57],
        [39]]
 
column_labels_2 = ["Data 2"]

#Creating a 2-dimensional dataframe out of the given data
df_2 = pd.DataFrame(data_2, columns = column_labels_2)

ax_2.axis('tight') # turns off the axis lines and labels
ax_2.axis('off')   # changes x and y axis limits such that all data is shown

#Plotting data
table_2 = ax_2.table(cellText = df_2.values,
        colLabels = df_2.columns,
        rowLabels = ["1", "2", "3", "4", "5",],
        rowColours = ["blue"] * 5,
        colColours = ["red"] * 5,
        loc = "center")

table_1.set_fontsize(12)
table_1.scale(0.1,1.5) # (width, height)

table_2.set_fontsize(12)
table_2.scale(0.1,1.5) # (width, height)
plt.show()

I am sure you can add additional tables if you follow the tutorials and this code.

Good luck.

1 Like

thanks bro i didnt knew this but i think thats what confusing people bcz other forum too they were asking similar but i didnt understood there.


thanks bro yes i want the output something like this where my input will be from excel and can we apply arrow here ?

what tools i need to learn to achieve this the output you shown it will be like 30 outputs there side by side with arrow as the direction .
and also can i do that in notebook or other software will i need ?

let’s divide the problem into three part.

  1. Read Excel
  2. Run the algorithm
  3. Output the result, chart here

The 1st part, you can use openpyxl. In this process, you are aim to read excel into python list (or list of dict maybe)

now, you have something like this

data = [
  [0, 3, 6],
  [1, 4, 7],
  [2, 5, 8],
]

just do whatever you want to data variable, you can use loop / index / condition etc.
and this is the second part.

finally, you should read about the ‘chart api’, and know what kind of data the chart need. Feed data to chart , then job is done.

Hi,

here is a code script with added arrows. I have also included the website tutorials from where I obtained the information from (first two were provided in previous posts, third one is new and it concerns adding arrows). All you need now is to learn how to read the information from an excel file from which other volunteers have provided you guidance on.

You will have to follow the tutorials to learn how to manipulate the arrow directions, placements, and sizes. I think that there is enough here to get you started.

Good luck to you.

Cheers!


'''
   1. https://www.scaler.com/topics/matplotlib/matplotlib-table/
   2. https://www.geeksforgeeks.org/how-to-create-multiple-subplots-in-matplotlib-in-python/
   3. https://matplotlib.org/stable/gallery/shapes_and_collections/arrow_guide.html#sphx-glr-gallery-shapes-and-collections-arrow-guide-py
'''

#import packages
import pandas as pd
import matplotlib.pyplot as plt

import matplotlib.patches as mpatches # Added for arrows

fig_1, (ax_1, ax_2) = plt.subplots(2,1)

# This is arbitrary data.  In your application, read it from an excel file
# and format it for plotting as shown here
data_1 = [[21],
          [32],
          [46],
          [37],
          [45]]

column_labels_1 = ["Data 1"]

#creating a 2-dimensional dataframe out of the given data
df_1 = pd.DataFrame(data_1, columns = column_labels_1)

ax_1.axis('tight') #turns off the axis lines and labels
ax_1.axis('off') #changes x and y axis limits such that all data is shown

#plotting data
table_1 = ax_1.table(cellText = df_1.values,
        colLabels = df_1.columns,
        rowLabels = ["1", "2", "3", "4", "5",],
        rowColours = ["blue"] * 5,
        colColours = ["red"] * 5,
        loc = "center")

# -----------------------------------------------------------------------

data_2 = [[35],
          [37],
          [86],
          [57],
          [39]]
 
column_labels_2 = ["Data 2"]

#Creating a 2-dimensional dataframe out of the given data
df_2 = pd.DataFrame(data_2, columns = column_labels_2)

ax_2.axis('tight') # turns off the axis lines and labels
ax_2.axis('off')   # changes x and y axis limits such that all data is shown

#Plotting data
table_2 = ax_2.table(cellText = df_2.values,
        colLabels = df_2.columns,
        rowLabels = ["1", "2", "3", "4", "5",],
        rowColours = ["blue"] * 5,
        colColours = ["red"] * 5,
        loc = "center")

# -+-+-+-+-+-+-+-+ START ARROW CODE -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Apply vertical arrow to first figure

x_tail = 0.8
y_tail = 1.3
x_head = 0.8
y_head = 0.2
dx = x_head - x_tail
dy = y_head - y_tail

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head),
                                 mutation_scale = 20)
ax_1.add_patch(arrow)

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head),
                                 mutation_scale = 20)
ax_1.add_patch(arrow)
ax_1.set(xlim = (0, 2), ylim = (0, 2))

# -+-+-+-+-+-+-+-+ END ARROW CODE -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

# -+-+-+-+-+-+-+-+ START ARROW CODE -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Apply horizontal arrow to second figure

x_tail = 0.4
y_tail = 0.1
x_head = 0.8
y_head = 0.1
dx = x_head - x_tail
dy = y_head - y_tail

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head),
                                 mutation_scale = 20)
ax_2.add_patch(arrow)

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head),
                                 mutation_scale = 20)
ax_2.add_patch(arrow)
ax_2.set(xlim = (0, 2), ylim = (0, 2))

# -+-+-+-+-+-+-+-+ END ARROW CODE -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

table_1.set_fontsize(12)
table_1.scale(0.1,1.5) # (width, height)

table_2.set_fontsize(12)
table_2.scale(0.1,1.5) # (width, height)

plt.show()

1 Like

thanks a lot bro