plot

Annotate lines of a plot with matplotlib when hover with mouse [duplicate]

核能气质少年 提交于 2021-02-08 05:29:54
问题 This question already has answers here : Possible to make labels appear when hovering over a point in matplotlib? (10 answers) Closed 1 year ago . I want to annotate different lines on a plot when hovering with the mouse, the same way is done here with points Possible to make labels appear when hovering over a point in matplotlib? I tried to adapt this code as the following : import matplotlib.pyplot as plt import numpy as np; np.random.seed(1) y = np.random.rand(4,15) x = [np.arange(15) for

How to add a wedge sector onto a polar Matplotlib plot

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 04:41:13
问题 I wish to add a wedge outlining a group of polar data using Python's Matplotlib. I have tried using the Wedge patch artist unsuccessfully, due to unknown reasons. I wish to either understand these unknowns, or find an alternative to the patch artist approach. The primary issue is that the Wedge patch is not displaying as I am expecting it to. Given my code, I am expecting it to be oriented at an angle, and span a range of ~0.05 in radius. This places it within the sector plot here: 1 But this

Plot points outside plotting region in R

断了今生、忘了曾经 提交于 2021-02-08 03:35:11
问题 I want to add points(asterisks) outside the plotting region of a plot in R. However, the following code only allows points to be added inside the plotting region: x = c(1:10) y = c(1:10) plot(x,y) points(11, 7, pch = 8) How can I adjust code to allow the point to be plotted outside the plotting region? 回答1: This SO post might help! It's about legends, but you can probably apply the same method for what you want. This worked for me: > par(xpd=TRUE) > x = c(1:10) > y = c(1:10) > plot(x,y) >

Plot points outside plotting region in R

时光怂恿深爱的人放手 提交于 2021-02-08 03:35:09
问题 I want to add points(asterisks) outside the plotting region of a plot in R. However, the following code only allows points to be added inside the plotting region: x = c(1:10) y = c(1:10) plot(x,y) points(11, 7, pch = 8) How can I adjust code to allow the point to be plotted outside the plotting region? 回答1: This SO post might help! It's about legends, but you can probably apply the same method for what you want. This worked for me: > par(xpd=TRUE) > x = c(1:10) > y = c(1:10) > plot(x,y) >

removing the ticks on the 3rd and 4th axes in plots from library effects in R

牧云@^-^@ 提交于 2021-02-08 03:01:06
问题 I'm wondering if there is a way to remove the tickmarks (the axes) on the 3rd and 4th axes of the plot generated by library effects as shown below? library(effects) m <- lm(Fertility ~ ., data = swiss) plot(allEffects(m), rug = FALSE) 回答1: It doesn't look like the package authors choose to expose that propertly very easily. We could write our own version of plot.efflist which is doing most of the work here. Here's the alternative version plot.efflist <- function (x, selection, rows, cols,

Fine control of bar width in barplot

て烟熏妆下的殇ゞ 提交于 2021-02-08 02:35:14
问题 I want to combine 4 figures in the same plot. Each barplot is related to the image plot. I want the bar width to be exactly the same width as the grid width in the image plot. The up-barplot and the left-barplot. I have pasted my code to follow. How can I modify for this purpose? Or can I use ggplot2 for this? datMat <- matrix(rep(1, 100), nrow=10) op=par(oma=c(1, 1, 1, 1), mar=c(1, 1, 1, 1), lwd=0.2, cex=.5) nf <- layout(matrix(c(0, 1, 0, 2, 3, 4), 2, 3, byrow=TRUE), widths=c(1, 6, 1),

Using pyplot to create grids of plots

♀尐吖头ヾ 提交于 2021-02-07 21:14:26
问题 I am new to python and having some difficulties with plotting using pyplot . My goal is to plot a grid of plots in-line ( %pylab inline ) in Juypter Notebook. I programmed a function plot_CV which plots cross-validation erorr over the degree of polynomial of some x where across plots the degree of penalization (lambda) is supposed to vary. Ultimately there are 10 elements in lambda and they are controlled by the first argument in plot_CV . So fig = plt.figure() ax1 = fig.add_subplot(1,1,1)

Using pyplot to create grids of plots

£可爱£侵袭症+ 提交于 2021-02-07 21:10:53
问题 I am new to python and having some difficulties with plotting using pyplot . My goal is to plot a grid of plots in-line ( %pylab inline ) in Juypter Notebook. I programmed a function plot_CV which plots cross-validation erorr over the degree of polynomial of some x where across plots the degree of penalization (lambda) is supposed to vary. Ultimately there are 10 elements in lambda and they are controlled by the first argument in plot_CV . So fig = plt.figure() ax1 = fig.add_subplot(1,1,1)

Using pyplot to create grids of plots

孤街浪徒 提交于 2021-02-07 21:04:30
问题 I am new to python and having some difficulties with plotting using pyplot . My goal is to plot a grid of plots in-line ( %pylab inline ) in Juypter Notebook. I programmed a function plot_CV which plots cross-validation erorr over the degree of polynomial of some x where across plots the degree of penalization (lambda) is supposed to vary. Ultimately there are 10 elements in lambda and they are controlled by the first argument in plot_CV . So fig = plt.figure() ax1 = fig.add_subplot(1,1,1)

How to plot categorical variable against a date column in Python

牧云@^-^@ 提交于 2021-02-07 20:40:05
问题 I have data that looks like this Date Fruit 2017-01-01 Orange 2017-01-01 Apple 2017-01-08 Orange 2017-01-09 Orange 2017-01-09 Apple I want to plot Number of Oranges, Number of Apples by Date in a single plot. How would I do that? I grouped them by Date and I see the result. df.groupby(['Date','Fruit']).size() Date Fruit 2017-01-01 Orange 1 Apple 1 2017-01-08 Orange 1 2017-01-09 Orange 1 Apple 1 I tried this but it gives a bar plot having two categories but not against the dates. sns.catplot(x