Shape-morphing systems can be found in many areas, including smart textiles, autonomous robotics, biomedical devices, drug delivery and tissue engineering. The natural analogues of such systems are exemplified by nastic plant motions, where a variety of organs such as tendrils, bracts, leaves and flowers respond to environmental stimuli (such as humidity, light or touch) by varying internal turgor, which leads to dynamic conformations governed by the tissue composition and microstructural anisotropy of cell walls. Inspired by these botanical systems, we printed composite hydrogel architectures that are encoded with localized, anisotropic swelling behaviour controlled by the alignment of cellulose fibrils along prescribed four-dimensional printing pathways. When combined with a minimal theoretical framework that allows us to solve the inverse problem of designing the alignment patterns for prescribed target shapes, we can programmably fabricate plant-inspired architectures that change shape on immersion in water, yielding complex three-dimensional morphologies.