Motivated by the shape of transportation networks such as subways, we consider a distribution of points in the plane and ask for the network G of given length L that is optimal in a certain sense. In the general model, the optimality criterion is to minimize the average (over pairs of points chosen independently from the distribution) time to travel between the points, where a travel path consists of any line segments in the plane traversed at slow speed and any route within the subway network traversed at a faster speed. Of major interest is how the shape of the optimal network changes as L increases. We first study the simplest variant of this problem where the optimization criterion is to minimize the average distance from a point to the network, and we provide some general arguments about the optimal networks. As a second variant we consider the optimal network that minimizes the average travel time to a central destination, and discuss both analytically and numerically some simple shapes such as the star network, the ring or combinations of both these elements. Finally, we discuss numerically the general model where the network minimizes the average time between all pairs of points. For this case, we propose a scaling form for the average time that we verify numerically. We also show that in the medium-length regime, as L increases, resources go preferentially to radial branches and that there is a sharp transition at a value Lc where a loop appears.