Have multi-dimension data, for example:
data pic
when i plot x,y chart out. matplot gives the x,y coordinate info at the bottom right corner when one moves the cursor around.
I am trying to add more info to the display, such as info1, info2 etc. on top of the x,y, either at the same corner, or popup when cursor moves on the chart.
Thanks
use libraries Plotly and Cufflinks for interactive charts
Here's a simple solution: use a 3d plot, and use color and size arguments with respect to different values of your other variables. That way, you can display a lot of information very easily.
Related
I need to draw additional graphics on top of plotly go.Box traces, therefore I need to know X and Y coordinates for boxplot rectangle vertices. So far the only solution I came up with is basically recalculating everything (quartiles; X positions based on boxgap, boxgroupgap, etc.), then manually setting the y-axis range to know where everything will end up on the plot. This seems very cumbersome.
Is there a way in python to get the coordinates of go.Box boxplot elements, especially the grouped boxplots with categorical x-axis? As far as I understand these coordinates are calculated in JS frontend -- maybe there is some trick to get them back with Dash using callbacks?
I use python's plotly to produce a figure. I want to legends (the two small squares in the top right) to be place on the top of the char due to space limitations in the width.
Can anyone point to me how?
You can use fig.update_layout(legend=dict(y=1.1, orientation='h')) to put your legend just above the charting area and make it horizontal:
you can use fig.update_layout(legend=dict(x, y)) to specify where the legend sits. x and y are in relation to the x and y axis
I want to plot boxplots on top of the scattered points like this.
I know I have to bin the data into intervals first but I couldn't find the function that does all of this. Sample x and y data are saved here as .npy.
I would look into using matplotlib. Boxes can be drawn as such:
https://matplotlib.org/gallery/pyplots/boxplot_demo_pyplot.html?highlight=boxplot
and scatter plots can also be drawn as such: https://matplotlib.org/gallery/lines_bars_and_markers/scatter_demo2.html?highlight=scatter
There is a search functionality on their site, along with plenty of documentation on how to utilize their library.
As for your specific question, you can specify zorder when drawing many of the things in matplotlib, and you could use that to define your boxplots to be on top. I believe if no zorder is defined that it draws items in the order they are encountered in your program (so you could draw scatter plots and then box plots and they should appear correctly as in your diagram above!
looking for some "magic" command that make the maps of the subplots (2x2 in my case) well speared not too much but with the right spacing in order to be considered "quality plot" I found that i can set all using the option rect inside plt.tight_layout I spend time to find this parameters : plt.tight_layout(rect=(0.02,0.02,0.97,0.97))
Now the plot is fitting well the pdf image but the 2 plots of the top is to close to the 2 below look the picture without going out of bound on the top ? and how can obtain the plot title a bit more separate respect the figure ? hope in your hint !
EDIT ok .. if I use the command plt.title('...',y=1.1) this is taken just on the last plot (the axs[1,1]) while I'm write the command before all the subplot !
Sorry I don't have an answer for automatic resizing but since you asked for some hints, there is one possible solution:
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots_adjust.html
What you need is wspace for horizontal spacing and hspace for horizontal spacing between the subplots. This gives you freedom to choose the desired spacing to make your plot a "quality plot". Hope it helps.
As to your second question about placing the title, you can use:
plt.title("Title here", y=1.25)
where y defines the position of your title in relative coordinates. y=1 would mean at the top x-axis and y=0.5 would mean in the centre of the plot. Since you have a title for each subplot, you can use the respective relative coordinates for each.
I'm now embedding matplotlib plot in a simple GUI. During the customization of the plot, I found some displaying issues occurred when I added tool bar under the plot using NavigationToolbar2TkAgg. Now I want to disable displaying coordinate at right side of the bottom of plot when mouse moves around the plot, if we add tool bars at the left side of the bottom. Any idea about this?
Thanks in advance.
Update:
For a figure simply drawn by plt.plot(x,y), the coordinates are displayed at left side of the bottom along with mouse moving as tool bars (like "home", "zoom" etc.) are listed at the top by default. It will be much clearer to view the screen shot at google drive here and I highlighted the coordinates in yellow, which one can find at the bottom left of the image. Thanks GWW and jgysland for reminding me.
You want the opposite of matplotlib values under cursor, but the solution is the same, you need to over-write the format_coord attribute on the Axes object.
ax.format_coord = lambda x, y: ''
should do the trick where ax is a reference to the axes object you care about.
Another option is to sub-class NavigationToolbar2TkAgg and make the set_message function a no-op
class my_toolbar(NavigationToolbar2TkAgg):
def set_message(self, msg):
pass