How to add subplot in python use matplotlib - python

I have a canvas to draw my figure in python and matplotlib
i want to add plot to that canvas dynamically
in fact i want to area of convas share bitwen all child plot
for example if canvas have only one plot, all area of canvas alocated to this and if add another plot to that canvas all area of canvas shared bitwen this tow plot and ...
Note: I do not know in advance how many plot(charts) I am going to add to canvas
thank you

Related

plot multiple figures in the same window but different "tabs" with matplotlib

I know that you can plot multiple figures in the same window by arranging them in a grid layout. However, I want to plot multiple figures, showing only one at a time and be able to move to the next or previous figure with buttons in the UI. I see arrows in the default UI which makes me think there's a way to do this.

Create resizable plot layout with different sized sections in Bokeh

Can I create a Bokeh layout where the widgets section is set to be e.g. 10% of the screen height with plot section at 90%?
I'm trying to avoid manually re-sizing my plot and using sizing_mode='fixed' which wouldn't work with resizing the browser window.
Currently have:
layout = layout(
[plot],
[[button, slider]],
sizing_mode='stretch_both'
)
In this case, the bottom half of screen is filled entirely by the stretched button/slider.
There is currently (as of 1.3.4) no mechanism to specify a percentage, but you can put the widgets in a row and give that a fixed height while letting the plot vary. Here is one way:
layout = column(
plot,
row(button, slider, height=100, sizing_mode="stretch_width"),
sizing_mode="stretch_both"
)

Bokeh legend scroll

When generating a bokeh plot using python with many categories, for instance a bar plot, the legend will not fit entirely in the screen and it is not possible to scroll.
Is there a way to scroll a legend?
Thank you
There is no scroll option for the legend.
Some suggestions from this answer:
The legend is drawn on the same canvas as the plot, so you could show more of your legend by increasing the plot size.
You could decrease the legend font size with p.legend.label_text_font_size = "8px"

Showing Matplotlib graphs in a canvas tkinter python 2.7

i want to display a graph in a canvas. The GUI was written in tkinter using python 2.7.
self.plotting(x, pa, y)
savefig("Omegakillerisawesome.png")
im=PhotoImage(file="Omegakillerisawesome.png")
self.canvasForGraph.create_image(500, 350, anchor=CENTER, image=im)
#show()
os.remove('Omegakillerisawesome.png')
The plotting function was implemented by me. accepting x,y values. so i'm hoping to show the graph in a canvas. so i'm saving the graph in the directory and reloading the image to the canvas. The problem is the .png file is not appearing in the canvas.
but if i uncomment the show() function the image comes up in the canvas as well as the usual window that graphs are displayed. i don't want that. i only want the graph to show up in the canvas.
please help. i'm a newbie.
[edit]
depth=[1,2,3,4,5,6]
temp=[9,8,7,6,5,4]
plot(depth,temp)
show()
this shows me a frame with my graph in it. but i want to do is display the graph inside a canvas widget using tkinter. but i dont want the usual frame that comes with the latter code. i just want the graph plotted inside the canvas no more.
that is what i'm trying to achieve from the first piece of code.
thanks.

Python Tkinter: set label background (in a canvas) to transparent

I'm trying to make a graph using tkinter and I want to have a monthly profit label situated above the point on the graph at which this profit is situated.
The problem I am having is the white background of the label is clipping off the lines in the line graph. Is there any way to set the label background to transparent?
I have tried calling the labels before I make the lines however the label is still on top of the lines when I did that.

Categories

Resources