0

I have a really easy data frame with two columns. We can just call them X and Y. Y is in feet and X is in cubic feet per second. I want to do a log graph and obtain the equation for the line but I have no idea how to accomplish this. I am guessing this is easier then I am making it out to be. I am currently using ggplot and I am getting really strange graphs. I attached a picture of what I am getting but the graph dows not make sense. It should be a straight line. graph

a %>% 
  ggplot(aes(Discharge, Gageheight)) +
  geom_point())

Thank you for your help!

Julian
  • 6,586
  • 2
  • 9
  • 33
ISJohnny
  • 7
  • 6
  • Hi OP, can you share a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? Share at least a portion of your data frame via copying and pasting into the question the output of `dput(your_df)` - should start with `structure(...`. Then also please share the plot code you are currently using, and if possible, an image of your current output. – chemdork123 Sep 02 '20 at 20:12
  • 1
    Thank you I added your suggestions. I am learning how to ask the questions so people understand. – ISJohnny Sep 02 '20 at 20:31
  • Maybe I need to adjust the x axis because the data goes to 25000 – ISJohnny Sep 02 '20 at 20:49
  • I added a picture of my odd results. Thank you for your time! – ISJohnny Sep 03 '20 at 15:23

1 Answers1

1

I tried to use a really simple dataset like yours and using this:

ggplot(data = easy_dataset, mapping = aes(x, y)) +
    geom_point()

It gave me the expected graph.

help-info.de
  • 6,695
  • 16
  • 39
  • 41
  • It is strange because I can get it to graph but the information looks really odd. Basically a bunch of lines one on top of another. . – ISJohnny Sep 02 '20 at 20:34
  • your code works for me but it gives rescaling problem using "coord_trans(x = 'log10')". What do you mean for information? Anyways you should log the data before putting them in ggplot and then using the new variable for the y axis. – Mattia Vinelli Sep 02 '20 at 20:44
  • It is almost like the graph is not large enough for the data. The graph has 11 lines gradually moving from 0 to the top of the y axis. – ISJohnny Sep 02 '20 at 20:47
  • ggplot(data = a, mapping = aes(Discharge, Gageheight)) + geom_point()+ xlim(15, 30000) – ISJohnny Sep 02 '20 at 21:21