plot(x,y) Error in plot.window(...) : need finite 'xlim' values

Hi Ruben, welcome!

You are not telling us what kind of plot you are trying to do, the error you are getting is because you are passing a character variable for the x-axis.

When posting questions here you are supposed to provide a REPRoducible EXample (reprex), since it seems like you are new to R, I'm going to make one for you this time. Is this close to the plot you want to do?

DataSetsCorto <- data.frame(stringsAsFactors=FALSE,
                            Latitud = c(-31.815, -30.254, -37.546, -23.908, -38.8, -37.478, -21.518,
                                        -33.655, -33.677, -21.617, -34.51, -45.572, -31.732,
                                        -24.145, -35.624, -38.634),
                            Longitud = c(-69.789, -71.248, -71.228, -67.261, -72.872, -74.437,
                                         -68.977, -72.045, -72.021, -68.48, -72.357, -76.723,
                                         -71.749, -67.581, -72.934, -75.285),
                            Profundidad = c(165.5, 56.4, 159.3, 254.2, 28.9, 23.3, 103.1, 25.7, 27.1,
                                            137.5, 19.4, 10, 22.6, 233.2, 15, 30.8),
                            Magnitud = c(3.6, 2.8, 3.7, 3.5, 2.5, 3.3, 3, 3.3, 3.2, 3.2, 2.5, 3.5,
                                         2.8, 4.2, 2.9, 2.9),
                            Epicentro = c("Mina Los Pelambres", "Andacollo", "Antuco", "Socaire",
                                          "Temuco", "Lebu", "Quillagua", "Navidad", "Navidad",
                                          "Ollagüe", "Pichilemu", "Melinka", "Los Vilos", "Socaire",
                                          "Constitución", "Tirúa"),
                            Distancia = c(75, 16, 46, 73, 25, 70, 60, 39, 35, 50, 35, 30, 30, 69, 57,
                                          15)
)

library(ggplot2)

ggplot(DataSetsCorto, aes(reorder(Epicentro, Magnitud), Magnitud)) +
    geom_point() +
    theme(axis.text.x = element_text(angle=45, hjust=1, vjust = 1))

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

1 Like