plot multiple column in a point and connect it with line

You can use xaxt and axis in base plot system.

dataset <- data.frame(CW = c(52095, 28312, 46430, 20385),
                      BF = c(12456, 1132, 39640, 5660),
                      TF = c(2265, 0, 0, 0),
                      CE = c(0, 0, 3397, 0),
                      row.names = c("Cla", "Clb", "Clc", "Cld"))

matplot(x = dataset,
        type = "o",
        lty = 1,
        lwd = 2,
        pch = 19,
        xlab = "Class",
        ylab = "Value",
        xaxt = "n")
axis(side = 1,
     at = 1:4,
     labels = rownames(x = dataset))
legend(x = "top",
       legend = names(x = dataset),
       col = 1:4,
       lty = 1,
       lwd = 2,
       pch = 19,
       ncol = 4,
       bty = "n")

Created on 2019-06-18 by the reprex package (v0.3.0)

Now that your problem is solved, will you please consider marking this thread as solved?

If you don't know how to do it, please take a look at this thread:

1 Like