How can I plot with 2 different y-axes?

update: Copied material that was on the R wiki at http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:2yaxes, link now broken: also available from the wayback machine Two different y axes on the same plot (some material originally by Daniel Rajdl 2006/03/31 15:26) Please note that there are very few situations where it is appropriate to use two different scales on the … Read more

Control the size of points in an R scatterplot?

Try the cex argument: ?par cex A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. Note that some graphics functions such as plot.default have an argument of this name which multiplies this graphical parameter, and some functions such as points accept a vector of values … Read more

Getting LaTeX into R Plots

The CRAN package latex2exp contains a TeX function that translate LaTeX formulas to R’s plotmath expressions. You can use it anywhere you could enter mathematical annotations, such as axis labels, legend labels, and general text. For example: x <- seq(0, 4, length.out=100) alpha <- 1:5 plot(x, xlim=c(0, 4), ylim=c(0, 10), xlab=’x’, ylab=TeX(r'($\alpha x^\alpha$, where $\alpha … Read more

how to draw directed graphs using networkx in python?

Fully fleshed out example with arrows for only the red edges: import networkx as nx import matplotlib.pyplot as plt G = nx.DiGraph() G.add_edges_from( [(‘A’, ‘B’), (‘A’, ‘C’), (‘D’, ‘B’), (‘E’, ‘C’), (‘E’, ‘F’), (‘B’, ‘H’), (‘B’, ‘G’), (‘B’, ‘F’), (‘C’, ‘G’)]) val_map = {‘A’: 1.0, ‘D’: 0.5714285714285714, ‘H’: 0.0} values = [val_map.get(node, 0.25) for node … Read more

Remove space between plotted data and the axes

Update: See @divibisan’s answer for further possibilities in the latest versions of ggplot2. From ?scale_x_continuous about the expand-argument: Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. The defaults are to expand the scale by 5% on each side … Read more

Moving x-axis to the top of a plot in matplotlib

Use ax.xaxis.tick_top() to place the tick marks at the top of the image. The command ax.set_xlabel(‘X LABEL’) ax.xaxis.set_label_position(‘top’) affects the label, not the tick marks. import matplotlib.pyplot as plt import numpy as np column_labels = list(‘ABCD’) row_labels = list(‘WXYZ’) data = np.random.rand(4, 4) fig, ax = plt.subplots() heatmap = ax.pcolor(data, cmap=plt.cm.Blues) # put the major … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)