Search code examples
pythonpandasmatplotlibcanvascustomization

How can I customize my graph figures in matplotlib.figure.Figure such as changing marker size?


The following code is in my matplotlib graphing class that I embedded into tkinter, and it creates the desired figure (shape of graph is correct):

df = pd.read_csv('data.csv')

fig = Figure(figsize=(12, 10), dpi=100)
fig.add_subplot(111).scatter(df['A'], df['B'])

canvas = FigureCanvasTkAgg(fig, master=self.parent)
canvas.draw()
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

The problem I'm having is styling the graph. How do I make the marker size significantly smaller? How do I customize the library to make it styled the way I want?

Edit: Image of how graph currently looks


Solution

  • Use the s parameter of scatter? See examples here

    fig.add_subplot(111).scatter(df['A'], df['B'], s=SOME_NUM)