1. A method for visualization, comprising: receiving an input indicative of respective apparent coordinates of a plurality of points disposed along a length of a probe inside a body of a subject, wherein the probe comprises a plurality of position transducers along the length of the probe inside a body of a subject; applying a model of known mechanical properties of the probe to the apparent coordinates so as to compute a cost function with respect to shapes that can be assumed by the probe in the body; choosing a shape responsively to the cost function; generating corrected coordinates of the points along the length of the probe based on the shape; and displaying a representation of the probe using the corrected coordinates, wherein the cost function is computed by: calculating an intrinsic energy representing a deviation of the probe from a free shape of the probe; calculating a position error between the model of known mechanical properties of the probe and the input indicative of respective apparent coordinates of the plurality of points disposed along the length of the probe; calculating an orientation error between the model of known mechanical properties of the probe and the input indicative of respective apparent coordinates of the plurality of points disposed along the length of the probe; and calculating the cost function as a weighted average of the intrinsic energy, the position error and the orientation error.