mhahsler / seriation

Infrastructure for Ordering using Seriation - R Package
GNU General Public License v3.0
75 stars 17 forks source link

Support for xlab and ylab #11

Closed Derek-Jones closed 4 years ago

Derek-Jones commented 4 years ago

seriation is a great package, but not being able to add labels (in the sense of xlab="From file", ylab="To file" is very frustrating).

Please add support for the functionality provided by xlab and ylab, in other plotting functions.

mhahsler commented 4 years ago

Hi,

there are several visualizations in seriation. Please post some code so I can have a look at it.

Regards, -MFH

Derek-Jones commented 4 years ago

Hi,

You are welcome to a copy of the data and the rest of the code. But the following is the core of the usage (the plot will appear in a book):

gfx_mat=matrix(data=0, nrow=length(f_node), ncol=length(f_node))
# gfx_mat[cbind(gfx$from, gfx$to)]=1/gfx$refs
gfx_mat[cbind(gfx$from, gfx$to)]=1+log(gfx$refs)
# gfx_mat[cbind(gfx$from, gfx$to)]=1

# gser=seriate(gfx_mat)
# gser=seriate(gfx_mat, method="BBURCG")

# Some trial and error finds "binary" gives the best clustering :-O
t=dissplot(dist(gfx_mat, method="binary"), # key=FALSE, col=rev(pal_col),
                method=list(inter="TSP", aggregation="Hausdorff"),
                plot=FALSE)

# Requested support for xlab and ylab
plot(t, options=list(key=FALSE, col=rev(pal_col)),
                xlab="From file", ylab="To file")
mhahsler commented 4 years ago

dissplot does not have xlab and ylab because it is made for showing clustered distance matrices where x and y contain the same sets of objects. What these objects are, goes typically into the main title. You do not seem to use cluster labels. I think what you want is to use pimage and use a seriation as the argument order.

Derek-Jones commented 4 years ago

I originally used seriate+image, but was getting poor results.

dissplot was tried in an attempt to improve the results, and I stuck with it when the image looked right. Copying the 'successful' options to seriate, produces the desired results :-)

Thanks for your patience.

Not sure if you are aware, but using the the col= option in seriate has no effect on the output produced by image, i.e., col=... has to appear in the call to image.

Derek-Jones commented 4 years ago

I have been using pimage+mtext.

It is not possible to change the size of the text given in xlab/ylab arguments (at least according to my reading of the source code).

Using pimage means there is space in the margin for mtext to put some text.

mhahsler commented 4 years ago

pimage uses grid (see ? grid). I don't think it mixes well with base R plotting functions like mtext. Have a look at https://stackoverflow.com/questions/41858987/using-mtext-with-lattice-plots-and-grid-arrange

Also, you can set cex using the gp argument in pimage.

Derek-Jones commented 4 years ago

Thanks for the link.

While mtext works for me, the example is part of a book and the gp argument approach looks like the approved approach (the call to gpar requires a to call library(grid))

Thanks once again for your suggestions.